least absolute deviation matlab

9 ビュー (過去 30 日間)
dav
dav 2013 年 7 月 2 日
Hi,
Is the a way to do parameter estimation using Least Absolute deviation with constraints in matlab.
If so, please let me know of a place to read about it.
thanks.

採用された回答

Matt J
Matt J 2013 年 7 月 2 日
If you are talking about the problem
min_x sum( abs(r(x)))
it is equivalent to
min_{x,d} sum(d)
s.t.
r(x) <=d
-r(x)<=d
The above formulation is differentiable if r(x) is differentiable, so FMINCON can handle it. You can obviously add any additional constraints you wish, so long as they too are differentiable.
  14 件のコメント
dav
dav 2013 年 7 月 18 日
編集済み: dav 2013 年 7 月 18 日
thank you.
I used your code to test the data set I have. BOTH parameter estimates should be 0.1. However, the estimates I get using your code are very different. is there a way to fix it. From a standard theory I know that when you regress the y vector I have mentioned on the x vector I should get parameters, both equal to 0.1
clc;
clear;
p=1;
T = 300;
a0 = 0.1; a1 = 0.1;
seed=123;
ra = randn(T+2000,1);
epsi=zeros(T+2000,1);
simsig=zeros(T+2000,1);
unvar = a0/(1-a1);
for i = 1:T+2000
if (i==1)
simsig(i) = unvar;
s=(simsig(i))^0.5;
epsi(i) = ra(i) * s;
else
simsig(i) = a0+ a1*(epsi(i-1))^2;
s=(simsig(i))^0.5;
epsi(i) = ra(i)* s;
end
end
epsi2 = epsi.^2;
y = epsi2(2001:T+2000); % THIS IS THE DATA SET I WANT TO TEST.
len = length(y);
x = zeros(len,p);
for i = 1:p
x(1+i:len,i) = y(1:len-i,1); % THIS IS THE x VECTOR
end
N=length(x);
e=ones(N,1);
f=[0,0,e.'];
A=[x(:),e,-speye(N);-x(:), -e, -speye(N)];
b=[y(:);-y(:)];
lb=zeros(N+2,1);
ub=inf(N+2,1); ub(1)=1;
%%Perform fit and test
p=linprog(f,A,b,[],[],lb,ub);
slope=p(1),
intercept=p(2),
Matt J
Matt J 2013 年 7 月 18 日
編集済み: Matt J 2013 年 7 月 18 日
All I can say is that I tested the example code I gave you. It worked fine for me and produced accurate estimates.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by