Nonlinear fit comparison - Matlab vs OriginLab
이전 댓글 표시
Good afternoon, I'm posting this question because I'm not able to find a satisfactory result of a non-linear fit with Matlab. On the contrary, OriginLab returns a good fit together with errors for fit parameters. Here my x and y data: x = [177600,961200, 2504000, 4997000, 8884000]; y = [6.754, 24.416, 58.622, 107.980, 154.507]; yErr = sqrt(y);
The fitting function is the following: y = V + (A-V)*S*x*EXP(-S*x) where V, A and S are the parameters which I need to calculate from the fit. OriginLab gives me the following:
- V = 1.978 ± 0.889
- A = 585 ± 64
- S = 4.392E-8 ± 6.771E-9
On Matlab I tried all the possible form of non-linear regression: fitnlm, lsqcurvefit, nlinfit etc... every time the same warning: The Jacobian is ill conditioned. Here is an example:
Nonlinear regression model:
y ~ a1 + (a2 - a1)*a3*x*exp( - a3*x)
Estimated Coefficients:
Estimate SE tStat pValue
__________ __________ ___________ __________
a1 -0.6789 2.9104e-19 -2.3327e+18 2.0265e-73
a2 530.78 8.0894e-20 6.5614e+21 3.2371e-87
a3 5.2511e-08 5.1865e-10 101.25 5.7063e-08
Of course such small standard errors are not reliable, but still I'm not able to reproduce the Origin results. Any suggestions?
댓글 수: 4
Star Strider
2018년 9월 14일
Using the genetic algorithm ga function (Global Optimization Toolbox), the best fit I got was with:
V = 7.550390625000001E-01
A = 5.476210479736328E+02
S = 4.920000007402336E-08
RN = 3.197638945910025E+00
where ‘RN’ is the norm of the residuals. (I constrained it to have only positive parameter estimates.)
I had a result which was near to this from Star Strider using fit using this code:
x = [177600,961200, 2504000, 4997000, 8884000]';
y = [6.754, 24.416, 58.622, 107.980, 154.507]';
x0 = [585 0 2];
fitfun = fittype('V + (A-V) *S .*x .* exp(-S .* x)');
[fitted_curve,gof,output] = fit(x,y,fitfun,'Start',x0)
scatter(x, y, 'r+')
hold on
plot(x,fitted_curve(x))
hold off
Results are:
fitted_curve =
General model:
fitted_curve(x) = V + (A-V) *S .*x .* exp(-S .* x)
Coefficients (with 95% confidence bounds):
A = 555 (423.4, 686.6)
S = 4.82e-08 (2.599e-08, 7.04e-08)
V = 0.8133 (-8.284, 9.91)
gof =
struct with fields:
sse: 10.5406
rsquare: 0.9993
dfe: 2
adjrsquare: 0.9986
rmse: 2.2957
output =
struct with fields:
numobs: 5
numparam: 3
residuals: [5×1 double]
Jacobian: [5×3 double]
exitflag: 2
firstorderopt: 1.3449e+08
iterations: 4
funcCount: 20
cgiterations: 0
algorithm: 'trust-region-reflective'
stepsize: 1.8486e-10
message: 'Success, but fitting stopped because change in coefficients less than tolerance (TolX).'
MZ123
2018년 9월 14일
MZ123
2018년 9월 14일
채택된 답변
추가 답변 (2개)
MZ123
2018년 9월 14일
0 개 추천
댓글 수: 2
Could you provide your code? Yesterday in the evening i tried to understand the problem you have. I did not get the exactly same result you provided from OriginLab, but it was a good fit i thinkand there was no warning. So it would be interesting to see what you are doing.
One more question to your fitting equation:
In your question it is:
y = V + (AV) * S * x * EXP (-S * x)
which should mean
A * V
In the Second Part of your question it is:
y ~ a1 + (a2 - a1) * a3 * x * exp (- a3 * x)
which is
A - V
MZ123
2018년 9월 14일
Alex Sha
2019년 9월 23일
0 개 추천
The global solution looks like below:
Root of Mean Square Error (RMSE): 1.42818042380826
Sum of Squared Residual: 10.1984966147457
Correlation Coef. (R): 0.999655170571204
R-Square: 0.999310460049744
Adjusted R-Square: 0.998620920099487
Determination Coef. (DC): 0.999310460049744
Chi-Square: 0.212210508410738
F-Statistic: 1449.24229503583
Parameter Best Estimate
---------- -------------
v 0.665211685653936
a 544.888484613983
s 4.9628897712431E-8
카테고리
도움말 센터 및 File Exchange에서 Linear Predictive Coding에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
