R:使用nls解析时出错

时间:2012-04-19 12:10:32

标签: 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: ~ 
  ^

有人能指出我哪里出错了吗?

1 个答案:

答案 0 :(得分:3)

尝试

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