0

I have parameter values that are specific to each time. I want to feed this parameter values to solve the following ODE: dN/dt = mu*N where mu = b*(X-12.2)^2. The Xvalue changes with time. Please see the code below that I came up with:

library(deSolve)
times = seq(from = 0, to = 2, by = 0.1)
X = c(57.20000, 57.19989, 57.18739, 57.08867, 56.80817, 56.31114, 55.61912,
         54.77622, 53.82779, 52.81217, 51.75900, 50.69015, 49.62139, 48.56372,
         47.52467, 46.50934, 45.52096, 44.56154, 43.63211, 42.73310, 41.86450)


N0 <- 1
b <- 7.45      # Model parameter
Xmin = 12.2

model <- function(t, y, parms) {
  with(as.list(c(y, parms)),{
   mu <- b*(X-Xmin)^2
    dN <- mu*N
    return(list(dN))
})
}


yini <- c(N=N0)
parms <- mu
t <- times

out <- ode(y=yini, times=times, func=model, parms=parms)

X values are specific to each time i.e. at t = 0, X = 57.2, t = 0.1, X = 57.19989 and so on....and these need to be supplied to calculate N over time. It is not working. Could anyone help with it?

Thanks,

KBH
  • 1
  • 2
  • Your parms (the values that do not change from step-to-step) are b and Xmin. mu cannot be a parm since it changes at every step. It would seem that you would want to estimate mu so it would best fit that data given that differential model, but that's not the way you are presenting the problem. – IRTFM May 14 '18 at 23:42
  • You are correct that mu is calculated using X value that varies with time. So, mu changes at each time step. With mu values available at each time step, I want to calculate N from that equations. The fact is mu is the parameter, function of X, and X changes with time. Therefore, mu is the function of time. I would have estimated mu if I had N value available. But, here I want to predict N value. Thanks again, hope now it is clear. – KBH May 15 '18 at 02:07
  • I thought `N0` would be `max(X)` and you would be predicting X at time `t` – IRTFM May 15 '18 at 03:49

0 Answers0