[R] nls help

Dieter Menne dieter.menne at menne-biomed.de
Wed Nov 30 19:27:02 CET 2011


chuck.01 wrote
> 
> 
> datum <- structure(list(Y = c(415.5, 3847.83333325, 1942.833333325,
> 1215.22222233333, 
> 950.142857325, 2399.5833335, 804.75, 579.5, 841.708333325, 494.053571425
> ), X = c(1.081818182, 0.492727273, 0.756363636, 0.896363636, 
> 1.518181818, 0.499166667, 1.354545455, 1.61, 1.706363636, 1.063636364
> )), .Names = c("Y", "X"), row.names = c(NA, -10L), class = "data.frame")
> 
> with(datum, plot(Y~X))
> 
> As you can see there is a non-linear association between X and Y, and I
> would like to fit an appropriate model.  I was thinking an exponential
> decay model might work well. 
> I tried the following (a and k starting values are based off of a lm()
> fit), but get an error. 
> 
> fit <- nls(Y ~ a*exp(-k * X), datum, start=c(a=3400, k=1867))
> 
> Error in nlsModel(formula, mf, start, wts) : 
>   singular gradient matrix at initial parameter estimates
> 

Try

plot(datum$X,datum$Y)

For more complex cases, plot the initial function you are trying to fit, but
in this case it is easy to see that k is more in the order of 2.

So try with k=2.

Dieter



--
View this message in context: http://r.789695.n4.nabble.com/nls-help-tp4123876p4124164.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list