R:使用 nls 解析时出错

标签 r nls

我正在尝试使用 nls 将高斯峰值拟合到 R 中的密度图。当我使用以下等式时:

fit <- nls(den.PA$y~coeffs2 * exp( - ((den.PA$x-coeffs3)/coeffs4)**2 ),
           start=list(coeffs2=1.12e-2, coeffs3=1075, coeffs4=2))

我收到以下错误:

Error in parse(text = x) : <text>:2:0: unexpected end of input
1: ~ 
  ^

谁能指出我哪里错了?

最佳答案

尝试

fit <- nls(y~coeffs2 * exp( - ((x-coeffs3)/coeffs4)**2 ),data=den.PA,
       start=list(coeffs2=1.12e-2, coeffs3=1075, coeffs4=2))

关于R:使用 nls 解析时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10227757/

相关文章:

R:如何为要通过 lm 或 nls 估计的模型添加约束?

r - qqplot + stat_smooth 错误

R nls : fitting a curve to data

r - 在数据集中拟合多条逻辑增长曲线

r - 在 R 中拟合函数

r - 使用 "rticles"包时如何更改 RMarkdown 中的字体?

r - ffbase::as.character 中的 "by"参数有什么作用?

r - 使用 "fread",如何从 csv 中删除注释行?

r - 镜像直方图,有代码但担心其丢弃数据?

r - 使用 rollapply 计算滚动相关性