Least Absolute Value based regression

21 ビュー (過去 30 日間)
abc
abc 2013 年 11 月 9 日
コメント済み: Amin Nassaj 2023 年 1 月 26 日
Hi ,
I want to use linear regression based on least absolute value deviation to find the coefficients of my model with the help of measured data and 3 independent variables. The number of measurements I have are much greater than 3( number of cofficients). I have been trying to implement LAV method for this, but with no success. I need urgent help. Can someone please guide me in this. If someone already has the code for LAV, I would be grateful if you could share it with me.
Thank you!

採用された回答

Matt J
Matt J 2013 年 11 月 10 日
With only 3 unknowns, fminsearch should work fairly well
fminsearch(@(x) norm(A*x-b,1), x0 )
  14 件のコメント
NA
NA 2021 年 10 月 29 日
編集済み: NA 2021 年 10 月 29 日
Hello Matt,
I have a regression model like:
zi = Ai1*x1+Ai2*x2+ei i=1,2,3,4,5
The observation are given as table below:
i = [1;2;3;4;5];
zi = [-3.01;3.52;-5.49;4.03;5.01];
Ai1 = [1;0.5;-1.5;0;1];
Ai2 = [1.5;-0.5;0.25;-1;-0.5];
AA = [i,zi,Ai1,Ai2];
T = array2table(AA);
T.Properties.VariableNames(1:4) = {'i','z_i','A_i1','A_i2'};
I used this code for LAV estimation
A = Ai1+Ai2;
b = zi;
len_x = size(A,2);
c = [zeros(len_x,1);ones(size(b))];
F = [A -eye(size(b,1)); -A -eye(size(b,1))];
g = [b; -b];
z = linprog(c,F,g);
xlav = z(1:2);
The result is not correct as xlav and residual should be
xlav = [3.005;-4.010]
residual = [0; 0.0125; 0.2; 0.02; 1]
Amin Nassaj
Amin Nassaj 2023 年 1 月 26 日
The problem is the way you have defined matrix A. It must be:
A=[Ai1 Ai2];
Then it works!

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

その他の回答 (1 件)

Matt J
Matt J 2021 年 10 月 29 日
@NA In the years after this thread, I implemented minL1lin, which you can download from
A quick test shows that it gives your expected answer:
zi = [-3.01;3.52;-5.49;4.03;5.01];
Ai1 = [1;0.5;-1.5;0;1];
Ai2 = [1.5;-0.5;0.25;-1;-0.5];
[xlav,~,res]=minL1lin([Ai1,Ai2],zi)
Optimal solution found.
xlav = 2×1
3.0050 -4.0100
res = 5×1
0.0000 -0.0125 -0.0200 -0.0200 0.0000
  12 件のコメント
NA
NA 2021 年 11 月 10 日
Thank you. If we change one of the entry of matrix A, such that
A_d = [A11 A12 A13 A14; A21 4*A22 A23 A24; A31 A32 A33 A34]
When we calculate residuals, how minL1lin removes the entry to find the regression. I mean, what is the threshold level that minL1lin use for regression?
Matt J
Matt J 2021 年 11 月 10 日
編集済み: Matt J 2021 年 11 月 10 日
I'm not really following you. What leads you to believe that elements of A are being removed?

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

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by