[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: leasqr with two variables
From: |
Michael Creel |
Subject: |
Re: leasqr with two variables |
Date: |
Mon, 14 May 2007 10:26:09 +0200 |
User-agent: |
Thunderbird 1.5.0.10 (X11/20070403) |
You just need a minimizer, and there are a lot of those around. For example,
bfgsmin, in octave-forge. The following script shows how to use it for this problem.
1;
function objval = my_model(theta, data)
p1 = theta(1,:);
p2 = theta(2,:);
p3 = theta(3,:);
p4 = theta(3,:);
y = data(:,1);
x1 = data(:,2);
x2 = data(:,3);
e = y - p1 - p2*x1 - (p3 + p4*x1) ./ x2;
objval = e'*e;
endfunction
n = 100;
theta = rand(4,1);
p1 = theta(1,:);
p2 = theta(2,:);
p3 = theta(3,:);
p4 = theta(3,:);
data = rand(n,3);
y = data(:,1);
x1 = data(:,2);
x2 = data(:,3);
y = p1 + p2*x1 + (p3 + p4*x1) ./ x2 + randn(n,1);
data(:,1) = y;
control = {100,2};
bfgsmin("my_model", {theta, data}, control);
To get standard errors, etc., you would probably be better off using
gmm_estimate, also in octave-forge (econometrics package).
Cheers, M.
Edvard Aasen wrote:
Hi
Im looking for a program that can find parameters in an equation with
two independent variables (X1 and X2) and experimental data Y. The
equation is
Y = p1 + p2*X1 + (p3+ p4*X1) / X2
X2 is temperature, X1 is molecular weight and Y is logaritm of viscosity
I have good start-values for the parameters
I have used leasqr for 1 variable but dont know how to expand it to two
parameters
I have done something similar in matlab (lsqcurvefit) some years ago but
i dont have access to malab today. Thanks for any ansvers
------------------------------------------------------------------------
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave