Question

I'm trying to fit Gaussian peaks to my density plots in R using nls. When I use the following equation:

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

I get the following error:

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

Can anyone point out to me where I have gone wrong?

Was it helpful?

Solution

Try

fit <- nls(y~coeffs2 * exp( - ((x-coeffs3)/coeffs4)**2 ),data=den.PA,
       start=list(coeffs2=1.12e-2, coeffs3=1075, coeffs4=2))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top