R Power Fit 与 nls 与 excel 不同
我有一个具有幂关系的数据集(如下)。 (Y =aX^b)
Excel 和 xmgrace 中的幂拟合给了我几乎相同的拟合值。 (R^2 为 0.993) Y = 215.47 X^0.812
但是,当我尝试 R 的 nls() 函数时,我得到了不同的值。另外,它不会计算 R^2,因为它在统计上不合理。
但是,如果我取对数,我可以执行 lm() 并得到 0.993 的 R^2。如何使用 R 重现 excel 和 xmgrace 产生的幂拟合值。R nls() 不正确吗?
Drift Time Mass_Independent CS
2.32 407.3417277
2.32 419.1267553
2.81 503.9859708
2.92 501.0465281
3.78 640.9024985
4.00 688.7906761
4.48 776.3958584
5.67 918.9991003
6.05 949.4448047
6.86 993.9763311
6.86 1064.539603
6.97 1041.422648
7.94 1112.407393
8.42 1183.070416
9.23 1302.622263
9.29 1291.525748
I have a data set (below) with a power relationship. (Y =aX^b)
The power fit in Excel and xmgrace gave me an almost identical values for the fit. (R^2 of 0.993)
Y = 215.47 X^0.812
However when I try R's nls() function I get a different value. Plus it does not calculate a R^2 because it is not statistically sound.
However if i take logarithms, I can do a lm() and get a R^2 of 0.993. How do I reproduce the values excel and xmgrace produce with power fits using R..Is R nls() not correct??
Drift Time Mass_Independent CS
2.32 407.3417277
2.32 419.1267553
2.81 503.9859708
2.92 501.0465281
3.78 640.9024985
4.00 688.7906761
4.48 776.3958584
5.67 918.9991003
6.05 949.4448047
6.86 993.9763311
6.86 1064.539603
6.97 1041.422648
7.94 1112.407393
8.42 1183.070416
9.23 1302.622263
9.29 1291.525748
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你相信 Excel 估计而不是 R 估计是愚蠢的。 Excel 在回归领域的失败由来已久且有据可查:
R 估计值以红色绘制。它表明您只关注参数估计而不查看 x=值范围内的预测是错误的。虽然您可以使用
anova()
进行模型比较,但没有真正的 R-sq 可以估计孤立非线性模型。欢迎您查找 nls (Douglas Bates) 的作者不包括它们的原因,因为它实际上是 r-help 邮件列表上的常见问题解答。I think you would be foolish to trust an Excel estimate over an R estimate. The failings of Excel in the domain of regression are longstanding and well documented:
The R estimate is plotted in red. It shows that you are wrong to focus on the parameter estimate without looking at the predictions over the range of the x=values. There is no real R-sq to estimate for solitary non-linear models, although you can do model comparisons with
anova()
. You are welcome to search out the reasons for the author of nls (Douglas Bates) not including them, because it is practically a FAQ on the r-help mailing list.