octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Least Absolute Deviation solution of a linear system


From: Michael Creel
Subject: Re: Least Absolute Deviation solution of a linear system
Date: Mon, 16 Feb 2009 01:32:30 -0800 (PST)

Regarding LAD estimation, it is possible to do with linear or nonlinear
models by defining the LAD objective function, and then using simulated
annealing to do minimization.  A function for simulated annealing
minimization is part of the Octave Forge optim package. An example of use
for LAD is:


###############  beginning of LAD example script
################################
n = 100;
e = randn(n,1);
x = [ones(n,1) randn(n,1)];
theta = ones(2,1);
y = x*theta + e;

printf("OLS fittted coefficients\n");
ols(y,x)

function obj_value = lad_obj(theta, y, x);
        e = abs(y - x*theta);
        obj_value = mean(e);
endfunction

# samin controls
ub = [2; 2];
lb = [-1; -1];
nt = 3;
ns = 3;
rt = .5;
maxevals = 1e6;
neps = 3;
functol = 1e-12;
paramtol = 1e-6;
verbosity = 1;
minarg = 1;
sacontrol = { lb, ub, nt, ns, rt, maxevals, neps, functol, paramtol,
verbosity, 1};  


printf("LAD fittted coefficients\n");
samin("lad_obj", {theta, y, x}, sacontrol); 
###############  end of LAD example script ################################


Running this results in the output:
octave:6> lad
OLS fittted coefficients
ans =

   1.0351
   1.0831

LAD fittted coefficients

================================================
SAMIN results

==> Normal convergence <==

Convergence tolerances:
Function: 1.000000e-12
Parameters: 1.000000e-06

Objective function value at minimum: 0.812300

           parameter        search width
            1.073272            0.000000
            1.124825            0.000000
================================================
octave:7>


Regards, Michael
-- 
View this message in context: 
http://www.nabble.com/Least-Absolute-Deviation-solution-of-a-linear-system-tp21617907p22034084.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]