Least Absolute Value based regression

6 vues (au cours des 30 derniers jours)
abc
abc le 9 Nov 2013
Commenté : Amin Nassaj le 26 Jan 2023
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!

Réponse acceptée

Matt J
Matt J le 10 Nov 2013
With only 3 unknowns, fminsearch should work fairly well
fminsearch(@(x) norm(A*x-b,1), x0 )
  14 commentaires
NA
NA le 29 Oct 2021
Modifié(e) : NA le 29 Oct 2021
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 le 26 Jan 2023
The problem is the way you have defined matrix A. It must be:
A=[Ai1 Ai2];
Then it works!

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 29 Oct 2021
@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 commentaires
NA
NA le 10 Nov 2021
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 le 10 Nov 2021
Modifié(e) : Matt J le 10 Nov 2021
I'm not really following you. What leads you to believe that elements of A are being removed?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Fit Postprocessing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by