Following is an excerpt from my data set: relative frequency and size. As you can see from the open-circles, this is a Gaussian distribution. I am using the nls
package in R to fit a nonlinear curve.
My equation is
or in plain text: c * e^(-(x - z)^2/l)
Here is how I got here
fit <- as.formula(y~c*(exp((-(x-z)^2/l))))
preview(fit_partial, data=mydata, start=list(c=0.005, x=mydata$x_values, z=130,l=2000))
The starting values seem reasonable. So I try to get a non-linear fit
nls_fit <- nls(fit, data=mydata, start=list(c=0.005, x=mydata$x_values, z=130, l=2000))
However, I'm thrown with an error
Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model
This is likely because my starting values are poor. Something else must be the issue though. Appreciate any help.