如何解决非线性最小二乘会导致 X 值较小的错误?
我正在创建一个 nls 模型,并且在我独立获取每年中的几个月时收到错误,而不是超过 2 1/2 年重复出现的几个月。为什么会这样?
例如:
library(ModelMetrics)
month Anas_clypeata
1 1 11.551399
2 2 10.380470
3 3 8.893374
4 4 6.279168
5 5 0.000000
6 6 2.973104
7 7 3.087721
8 8 5.000119
9 9 5.968928
10 10 7.264972
11 11 9.692909
12 12 10.667599
model <- nls(Anas_clypeata ~ SSlogis(month,a,b,c),data=xp)
步长因子 0.000488281 低于 'minFactor' 0.000976562
上面的数据集仅适用于一年,但是,当我包含多个年份并且月份重复出现时(因为 pls 需要唯一值),它可以工作 -
# A tibble: 30 x 2
month Anas_clypeata
<int> <dbl>
1 1 11.6
2 2 10.4
3 3 8.89
4 4 6.28
5 5 0
6 6 2.97
7 7 3.09
8 8 5.00
9 9 5.97
10 10 7.26
# … with 20 more rows
model <- nls(Anas_clypeata ~ SSlogis(month,data=top_50.wide)
Nonlinear regression model
model: Anas_clypeata ~ SSlogis(month,c)
data: top_50.wide
a b c
7.004 27.250 -1.960
residual sum-of-squares: 287.2
Number of iterations to convergence: 0
Achieved convergence tolerance: 3.373e-06
知道为什么后者有效而前者失败吗?
这是数据集的副本:
structure(list(month = 1:30,Anas_clypeata = c(11.5513989077551,10.3804697649405,8.89337381185557,6.27916807383836,2.97310406664903,3.0877208020645,5.00011927833925,5.96892813407019,7.26497154463541,9.69290917089136,10.6675991606799,11.8590886929788,12.3291352672781,9.1835226010223,6.30175959321231,3.48230465652211,3.0273598825369,3.05144727149347,5.00386290939039,6.33602544591679,7.39790406541696,8.99503119998143,10.3268728899242,2.97626807453518,2.10458680385586,3.35678755617876,4.05239330935194,1.77213386289857,1.997459721803
)),row.names = c(NA,-30L),class = c("tbl_df","tbl","data.frame"
))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。