r - nls 中的错误,步长因子降低到 minFactor 以下

标签 r nls

我有以下数据框:

> dput(df_acf)
structure(list(x = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), y = c(1, 
0.0595936565187637, 0.0376022880804335, 0.0521100393333187, 0.0720561234389795, 
0.0262258507877819, -0.0126644770510529, 0.18604968147151, 0.115018192163521, 
-0.0476175556946567, -0.183213245514104)), class = "data.frame", row.names = c(NA, 
-11L))

我想使用这个非线性函数来拟合

f <- function(t, coeff_sigma, coeff_alpha,coeff_omega) {
  coeff_sigma * exp(-coeff_alpha*t)*cos(coeff_omega*t)
}

但是,当使用nls

fit <- nls(y~f(x,coeff_sigma,coeff_alpha,coeff_omega), data=df_acf, start=list(coeff_sigma=0.8, coeff_alpha=0.62, coeff_omega=0.65),control = nls.control(maxiter = 1000))

我收到此错误:nls 中出现错误,步长因子降低至 minFactor 以下

最佳答案

如果您对其他参数模型持开放态度,那么这很容易适合:

fo <- y ~ a * (1 + b * x) ^ -c
fit2 <- nls(fo, df_acf, start = list(a = 1, b = 1, c = 1))

plot(df_acf)
lines(fitted(fit2) ~ x, df_acf, col = "red")

给予:

screenshot

关于r - nls 中的错误,步长因子降低到 minFactor 以下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73289765/

相关文章:

r - 使用 nls 拟合威 bool 模型

r - 防止 R Studio 收到 'skipping' 注释。运行每行

r - 错误打破for循环: conditional try statement?

r - 使用 nls 函数错误拟合

r - R中的变点检测

r - 使用 nls 将曲线拟合到 R 中的威 bool 分布

r - 在 R 中使用带有 SSlogis() 和 predict() 的 nls() 的未知错误消息

r - 如何在使用 pRoc 包进行 ROC 分析后获得 p 值?

r - data.tables 的 Shiny react 失败

r - R中的zoo对象和ts对象有什么区别?