0

I want to use nls to fit an exponential function to my data :

X <- c(0:40)
Y <- c(0, 0.007515662, 0.015878514, 0.024994325, 0.034728341, 0.044910579, 0.055344590, 
       0.065818599, 0.076118441, 0.086040566, 0.095403934, 0.104059903, 0.111898792, 
       0.118853016, 0.124896650, 0.130041857, 0.134332925, 0.137838655, 0.140644404,  
       0.142844161, 0.144533652, 0.145804788, 0.146741667, 0.147418108, 0.147896553, 
       0.148228057, 0.148453067, 0.148602679, 0.148700131, 0.148762313, 0.148801181, 
       0.148824980, 0.148839256, 0.148847645, 0.148852473, 0.148855195, 0.148856698, 
       0.148857511, 0.148857941, 0.148858164, 0.148858276)

mod <- nls(Y ~ (f - exp(a + b*X + d*X^2)), start = selfStart)

But it does not work ! it returns the following error :

  Error in nls(Y ~ (f - exp(a + b * X + d * X^2)), start = selfStart) : 
  parameters without starting value in 'data': f, a, b, d

How could I fix this ?

Haribo
  • 2,071
  • 17
  • 37
  • 1
    You have to provide starting values. – G. Grothendieck Oct 22 '18 at 14:21
  • @G.Grothendieck, So what about `selfStart` command then ? how could I avoid to put initial values ? – Haribo Oct 22 '18 at 14:39
  • You can't omit starting values on arbitrary formulas. Only very specific ones that use predefined functions that have self starting builtin such as SSlogis, SSasymp and others. Try `apropos("^SS")` to list them. – G. Grothendieck Oct 22 '18 at 23:31

0 Answers0