Constrained linear least squares
显示 更早的评论
Hi everyone! I have a set of data such as:
y=[0.007696733 0.004758526 0.00547575 0.009628829 0.009749457 0.009073008 0.009647521 0.009795106 0.014071997 0.014208544 0.01758061 0.015072178 0.018425671 0.019217437 0.020314108 0.018246917 0.022694743 0.041827743 0.040799924 0.033812901 0.043516698];
y(t)=y(2:n);
y(t-1)=y(1:n-1);
I want to figure out the two parameters [b,c] of: y(t)=(1+b)*y(t-1)-b/c*(y(t-1))^2

What's more the two parameters need to be over 0;
Thank you so much for reading my question!
回答(1 个)
Star Strider
2014-7-1
编辑:Star Strider
2014-7-1
It is actually nonlinear, because it is nonlinear in the parameters (the partial derivatives of the function with respect to each parameter are functions of themselves or of other parameters).
Using lsqcurvefit (Optimization Toolbox), the code is:
n = length(y);
yd = y(2:n);
yi = y(1:n-1);
f = @(B,y) (1 + B(1)).*y - (B(1)./B(2)).*y.^2; % Objective function
yp = linspace(min(yi), max(yi)); % Plot vector for ‘yi’
bc = lsqcurvefit(f, rand(2,1)*100, yi, yd, [1; 1]*eps, [Inf; Inf])
figure(1)
plot(yd, yi, 'xb')
hold on
plot(yp, f(bc,yp), '-r')
hold off
grid
The fit produces:
b = 2.989459285195542E-01
c = 3.990401160101856E-02
b/c = 7.491625942488537E+00
类别
在 帮助中心 和 File Exchange 中查找有关 Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!