这是我用于Y数据的数据:
0.577032413537833
0.288198874369377
0.192282280031568
0.143824619265244
0.114952782524097
0.0960518606520442
0.0824041879978560
0.0719078360110914
0.0640919744028295
0.0572120310249072
0.0519630635470660
0.0479380073164273
0.0443712721513307
X只是从1到13的整数值,我知道这是在MATLAB上运行GUI cftool时形成a * x ^ b + c的幂函数,具有相当高的R平方值(1)
为了在命令行上执行fit,我使用了:
>> g = fittype('a*x^b+c','coeff',{'a','b','c'})
>> x=1:13;
>> [c3,gof3] = fit(x',B3(:,1),g)
这导致
c3 =
General model:
c3(x) = a*x^b+c
Coefficients (with 95% confidence bounds):
a = -179 (-1.151e+005, 1.148e+005)
b = 0.001066 (-0.6825, 0.6847)
c = 179.5 (-1.148e+005, 1.151e+005)
gof3 =
sse: 0.0354
rsquare: 0.8660
dfe: 10
adjrsquare: 0.8392
rmse: 0.0595
与
不一样General model Power2:
f(x) = a*x^b+c
Coefficients (with 95% confidence bounds):
a = 0.5771 (0.5765, 0.5777)
b = -1.001 (-1.004, -0.9983)
c = -8.972e-005 (-0.0005845, 0.000405)
Goodness of fit:
SSE: 4.089e-007
R-square: 1
Adjusted R-square: 1
RMSE: 0.0002022
当我在cftool GUI界面上运行回归时,我得到了。我在这里缺少哪些选项让我看似模特的结果却截然不同? a = -179非常可疑......
提前感谢您的意见。
哦,一旦我把它们排除在外,是否有办法从拟合的模型中获得特定的价值?说,我只对A的价值感兴趣。
对于gof,我知道我可以通过使用gof.rsquare来提取...等等,但对于cfit怎么样?
答案 0 :(得分:4)
当我尝试
时>> g = fittype('a*x^b+c','coeff',{'a','b','c'})
>> x=1:13;
>> [c3,gof3] = fit(x',B3(:,1),g)
我得到了
Warning: Start point not provided, choosing random start point.
> In Warning>Warning.throw at 31
In fit>iFit at 320
In fit at 109
所以我把它改成了
>> [c3,gof3] = fit(x', B3(:,1),g, 'Startpoint', [0 0 0])
给了我
c3 =
General model:
c3(x) = a*x^b+c
Coefficients (with 95% confidence bounds):
a = 0.5771 (0.5765, 0.5777)
b = -1.001 (-1.004, -0.9983)
c = -8.972e-05 (-0.0005844, 0.000405)
这确实比你从cftool
GUI获得的更接近。
很可能“随机起点”对于GUI来说比使用CLI更好,所以你很幸运。
如果可以一致地生成这些结果,那么必须将GUI编程为在可用时使用全局优化工具箱,或者某些类似的方案。但这只是疯狂的猜测。