[R] using lsoda() and nls() together

Thomas Petzoldt thpe at simecol.de
Wed May 27 00:06:26 CEST 2009


Hi Benoit,

your problem is not really a problem of lsoda. The reason of the "crash" 
is a violation of the statistical assumptions of least squares 
regression due to dependency of residual variance on x. Due to this, K1 
is varied over a very large range of values until numeric overflow occurs.

Note that you have an exponentially growing state, so log transformation 
will help:

	
res <- nls(log(foo) ~
   log(func(K1)),start=list(K1=1),data=data.frame(foo=y), trace=TRUE)

summary(res)


You may also consider using packages simecol (on CRAN) or FME (on 
R-Forge) that both support constrained optimization of ode systems.

Hope it helps

Thomas Petzoldt




More information about the R-help mailing list