Nonlinear least square regression
Show older comments
i have (x , y) data
the function between x and y is y = 0.392* (1 - (x / b1) .^ b2
i want to use nonlinear least square regression to obtain the values of b1 and b2
can any one help me with the structure of the Matlab program
thanks in advance
1 Comment
Answers (1)
the cyclist
on 27 May 2013
If you have the Statistics Toolbox, then you can use the nlinfit() function.
Type
doc nlinfit
8 Comments
NLINFIT seems to think that y(t) = .392* exp(-t) is a pretty good model for your data. Note that this is the same as
y(t) = lim_n-->inf 0.392*(1+t/n)^n
so the fitting algorithm will obviously look for large x(i) in your proposed model. Your data does look vaguely exponential...
ameen
on 27 May 2013
which one is correct ???
Both of them. As you can see from running the code below, they both produce virtually identical curves. Again, this is because making your parameters large causes the curve to converge to 0.392*exp(-t).
t=sort(t);
f=@(t,x) 0.392*(1-(t./x(1))).^x(2);
beta=[1.9793 2.0014]*1e9;
x =[258.1339 261.1441];
plot(t,f(t,beta), '*-' ,t,f(t,x),'o--',t,0.392*exp(-t),'d-.')
legend('Using Beta','Using x','Using 0.392*exp(-t)')
ameen
on 27 May 2013
Or your model. Maybe you should be fitting
y=x(1)*exp(-x(2)*t)
Categories
Find more on Nonlinear Regression 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!