[R] ode first step

Benoit Boulinguiez benoit.boulinguiez at ensc-rennes.fr
Thu May 14 14:21:32 CEST 2009


As I do not thoroughly understand the way 'lsoda' works, I face some
difficulties to 'get' myself into the function(), though I changed the code
as follows:

------------------------------
require(deSolve)

qm<-0.36
y0<-c(0)
parms<-c("K1","K2")
times<-seq(0,10000,1)
kinetic.model<-function(t,y,parms){
	dq.dt = K1*C0 - (K1*m/V+ K2)*q
	list(dq.dt)
	}

foo<-lsoda(y0,times,kinetic.model,parms)
	Error in func(time, state, parms, ...) : object 'K1' not found
------------------------------

'K1' and 'K2' are parameters but 'C' is not a parameter, it's a dependant
variable of the time.
I actually express it as a function of q(t) to get this new equation
			dq/dt= K1*C0 - (K1*m/V+ K2)*q(t)
where K1 and K2 are the unknown but desired parameters and {C0,m,V} are
constant known values.

Nevertheless, I still get this 'Error about object 'K1' not found'.





Regards/Cordialement


Benoit Boulinguiez 


-----Message d'origine-----
De : Dieter Menne [mailto:dieter.menne at menne-biomed.de] 
Envoyé : jeudi 14 mai 2009 12:12
À : 'Benoit Boulinguiez'
Objet : RE: [R] ode first step

Try to hide yourself inside the function(). What would you see? No K1, for
sure, no C, no  K2.
These are passed through parms, so parms["K1"] would work, but not for C,
you should add it.

-----Original Message-----
From: Benoit Boulinguiez [mailto:benoit.boulinguiez at ensc-rennes.fr]
Sent: Thursday, May 14, 2009 11:53 AM
To: 'Dieter Menne'
Subject: RE: [R] ode first step

------------------------------
qm<-0.36
y0<-c(0)
parms<-c(K1=1,K2=1)
times<-seq(0,10000,1)
kinetic.model<-function(t,y,parms){
	dq.dt<- K1*C*(qm-q)-K2*q
	list(dq.dt)
	}

require(deSolve)
nls(foo<-lsoda(y0,times,kinetic.model,parms)




More information about the R-help mailing list