jamaas wrote: > > I'm just getting to grips with using ode function and have used the > examples and vignettes to produce a small model of a one-pool, > michaelis-menten, enzyme kinetic reaction. The rate of flux of substrate > into pool A is constant (fluxoa) however the rate of flux out of pool A > is controlled by the HMM equation (v = Vmax/ ( 1 + (Km / Concentration A > )) ). This function works fine and gives correct answers for the > size of the pool of quantity of substrate in pool A at all times, > however if possible I'd like to also extract the values of interim > variables at each time t. Could anyone give me a clue of how to include > the value of CA at each time t, along with QA in the results? > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > Thanks > > Jim > > R code > ================== > parameters <- c(vola = 17.3629, vmax = 4.7, mmk = 0.5435, fluxoa = > 2.389) > state <- c(QA=9.437) > > MM <- function(t, state, parameters) { > with(as.list(c(state, parameters)),{ > ## concentration of substrate in pool A, quantity > ## divided by the volume of the solvent pool > CA <- QA/vola > ## output of substrate from pool A > fluxao <- vmax / (1 + (mmk/CA)) > ## rate of change of quantity of substrate > ## in pool A > dA <- fluxoa - fluxao > ## return the rate of change > list(dA) > }) > } > > times <- seq(0, 100, by = 5) > library(deSolve) > out1 <- ode(y = state, times = times, func = MM, parms = parameters) > head(out1) >
See this very recent post on R-help: http://r.789695.n4.nabble.com/deSolve-output-td3738970.html And a reply: http://r.789695.n4.nabble.com/deSolve-output-td3740431.html Modify your function to this MM <- function(t, state, parameters) { with(as.list(c(state, parameters)),{ ## concentration of substrate in pool A, quantity ## divided by the volume of the solvent pool CA <- QA/vola ## output of substrate from pool A fluxao <- vmax / (1 + (mmk/CA)) ## rate of change of quantity of substrate ## in pool A dA <- fluxoa - fluxao ## return the rate of change list(dA, CA=CA) ### <<<=== Add stuff at the end }) } It is in the documentation for ode (in the description of "func") Berend -- View this message in context: http://r.789695.n4.nabble.com/deSolve-extracting-variable-values-from-inside-ode-function-tp3746701p3747362.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.