Info
此问题已关闭。 请重新打开它进行编辑或回答。
How can I obtain the coefficient values, confidence intervals by the Fit
1 次查看(过去 30 天)
显示 更早的评论
hello, I'm new to Matlab, I have this equation:
c.*(((a+1./sqrt((1/b).^2+X.^2))./((1/b).^2+X.^2).*exp(-a.*sqrt((1/b).^2+X.^2)))+5.33267*(a+1./(sqrt((5.33267./b).^2+X.^2)))./((5.33267./b).^2+X.^2).*exp(a.*sqrt((5.33267./b).^2+X.^2)))./(4.*pi.*b)
I have to fit to find the two parameters a and b. The X and Y are:
X= [1.5 2 3 4 4.5 6 7.5 8 9 10 10.5 12 13.5 14 15 16 16.5 18 19.5 20 21 22 22.5 24 26 28 30 ];
Y=[2.029 0.796 0.456 0.24 0.204 0.122 0.077 0.061 0.053 0.042 0.035 0.027 0.021 0.02 0.017 0.016 0.015 0.015 0.013 0.012 0.01 0.009 0.009 0.008 0.007 0.0067 0.006];
knowing that a must be between [0,01732-0.95]; and b must be between [1.0001-3.1].
Thank you in advance for your help
0 个评论
回答(1 个)
Star Strider
2014-4-3
I replaced: a = P(1), b = P(2), c = P(3) but otherwise did not change your function:
f = @(P,X) P(3).*(((P(1)+1./sqrt((1/P(2)).^2+X.^2))./((1/P(2)).^2+X.^2).*exp(-P(1).*sqrt((1/P(2)).^2+X.^2)))+5.33267*(P(1)+1./(sqrt((5.33267./P(2)).^2+X.^2)))./((5.33267./P(2)).^2+X.^2).*exp(P(1).*sqrt((5.33267./P(2)).^2+X.^2)))./(4.*pi.*P(2));
X = [1.5 2 3 4 4.5 6 7.5 8 9 10 10.5 12 13.5 14 15 16 16.5 18 19.5 20 21 22 22.5 24 26 28 30 ];
Y = [2.029 0.796 0.456 0.24 0.204 0.122 0.077 0.061 0.053 0.042 0.035 0.027 0.021 0.02 0.017 0.016 0.015 0.015 0.013 0.012 0.01 0.009 0.009 0.008 0.007 0.0067 0.006];
P0 = [0.5; 2.0; 1.0];
[B,resnorm,residual,exitflag,output,lambda,J] = lsqcurvefit(f, P0, X, Y, [0.01732; 1.0001; -Inf], [0.95; 3.1; Inf]);
Bci = nlparci(B,residual,'jacobian',J);
[Ypred,delta] = nlpredci(f,X,B,residual,'Jacobian',J);
figure(1)
plot(X, Y, 'xb', 'LineWidth',1.5)
hold on
% plot(X, Ypred, '-r')
errorbar(X, Ypred, delta, '-r')
plot(X, Ypred, '-r')
hold off
legend('Data', 'Predicted ±95% CI', 'Location', 'NorthEast')
grid
sprm = ['a'; 'b'; 'c'];
fprintf(1,'Parameter Estimates and 95%%Confidence Intervals:\n')
for k1 = 1:3
fprintf(1,'\t%s = %13.5E\t(%13.5E %13.5E)\n', sprm(k1), B(k1), Bci(k1,:))
end
You did not specify what ‘c’ is, so I added it as P(3), a parameter to be estimated. I used the Optimization Toolbox function lsqcurvefit to fit your data, because the Statistics Toolbox function nlinfit does not allow for constrained parameter estimates. The other functions, nlparci and nlpredci are Statistics Toolbox functions.
Unfortunately, neither a nor b are statistically significant:
Parameter Estimates and 95% Confidence Intervals:
a = 1.73200E-02 ( -2.26964E-01 2.61604E-01)
b = 3.08837E+00 ( -1.26825E+00 7.44499E+00)
c = 9.51825E+01 ( 1.60626E+01 1.74302E+02)
1 个评论
Martín Menéndez
2017-4-22
编辑:Martín Menéndez
2017-4-22
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!