Skip to content
Prev 272 / 696 Next

[R-sig-dyn-mod] hmax and its role in ode

Hi Andras:

One possible kludge to ensure positive numbers is to transform the state variable using natural logs and solve for that. The idea is built around the fact that 

d(ln x) / dt = (1/x) * (dx/dt)

In your case, the model function might look something like this:

Model<-function(t, logx, pars){
	x<-exp(logx)
	dxdt<- (-Ka * x)
	return(list(dxdt/x))
}

When solving the model, you initially pass the natural log of the state variable to ode() instead of the state variable itself. Also, you'd need to transform the solution afterwards (i.e., exp[solution]). As I say, it's a kludge, but hopefully it helps...

Cheers,
Daniel

_______________________________
Daniel C. Reed, PhD.
Postdoctoral Fellow,
Dept. of Earth & Environmental Sciences,
University of Michigan,
Ann Arbor, MI, USA.
email: reeddc at umich.edu
web: www.danielreed.org
On Oct 23, 2013, at 8:15 AM, Karline Soetaert <Karline.Soetaert at nioz.nl> wrote: