Why do I receive different results using the NLINFIT function in the Statistics Toolbox 5.0 (R14) and 4.1 (R13SP1)?
1 view (last 30 days)
Show older comments
I use the following code that contains a call to the NLINFIT function:
x = [1 2 3 4 5 6 7 8 9 10];
y = [0.473 0.929 1.386 1.851 2.323 2.779 3.242 3.706 4.171 4.621];
beta=[200;0.2]; %Initial estimate of beta
beta = nlinfit(x,y,@modelfun,beta);
My objective function "modelfun" is defined as follows:
function yhat=modelfun(beta,x);
e = beta(1);
f = beta(2);
a = 2/e;
b = (4 + x.^2*pi^2/2) / e^2;
c = x*f;
yhat = (1 + a + b).*c;
Executing this code In MATLAB 6.5.1 (R13SP1), I obtain the following:
beta(1) = 309.0739
beta(2) = 0.4585
But in MATLAB 7.0 (R14), my results are as follows:
beta(1) = -2.2763e+007
beta(2) = 0.4630
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The implementation of the NLINFIT function has changed between the Statistics Toolbox 4.1 (R13SP1) and 5.0 (R14). In R13SP1, NLINFIT uses the Gauss-Newton algorithm. In R14, NLINFIT uses the Levenberg-Marquardt algorithm.
Note: the result returned in R14 is in fact better then the result returned by R13SP1. This can be verified by looking at the residues in both cases. In addition note that this example contains multiple minima and the value of the coefficients returned, depends on the initial estimates of the parameters.
0 Comments
More Answers (0)
See Also
Categories
Find more on Financial Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!