[R] nls power law help

JenPool j.e.kelly at student.liv.ac.uk
Sun Jul 14 15:30:53 CEST 2013


Hi,

I am trying to use a power law y=bx^a as a nls model as below, however I
keep getting 'singular gradient' error. I have tried multiple different
starting values but always get an error. 

> x2 <-
> c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
> 31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63)
> y2 <- 
> c(2326.0,2635.5,2875.0,3096.0,3265.5,3455.0,3618.0,3785.0,3936.0,4087.0,4214.0,4355.0,
> 4488.0,4615.0,4735.5,4866.0,4981.5,5089.5,5202.5,5318.0,5438.0,5537.0,5636.5,5748.0,5853.0,
> 5967.0,6042.5,6166.0,6259.5,6358.0,6452.0,6551.5,6645.0,6742.5,6839.0,6930.0,7026.0,7123.0,
> 7207.0,7300.0,7387.5,7481.5,7574.5,7663.0,7752.0,7831.5,7915.0,8005.0,
> 8091.5,8183.5,8260.0,8360.0,8441.0,8525.5,8606.0,8691.5,8779.0,8863.5,8941.5,9030.0,9108.0,9195.0,9271.0)


> df <- dataframe(x=x2,y=y2)
> model <- nls(y2~b*x2*exp(a),data=data2,start=list(a=0.7,b=3000))
Error in nlsModel(formula, mf, start, wts) : 
  singular gradient matrix at initial parameter estimates
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

Any ideas?

Thanks,
Jen



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



More information about the R-help mailing list