I have an equation as below;
dN/dt = N(t)G(t)
G(t)
is given by the equation: dG/dt = a * G
How do I solve this in R, using ode function from deSolve package?
I have an equation as below;
dN/dt = N(t)G(t)
G(t)
is given by the equation: dG/dt = a * G
How do I solve this in R, using ode function from deSolve package?
As dario already mentioned, the question lacks some details. Nevertheless, let's try an answer. If we assume that a < 0
, the model looks like the ode formulation of Gompertz growth:
dN/dt = N * G
dG/dt = a * G
This can then be solved as:
library(deSolve)
model <- function(t, y, p) {
with(as.list(c(y, p)), {
dN <- N * G
dG <- a * G
list(c(dN, dG))
})
}
y <- c(N = 1, G = 1)
parms <- c(a = -0.1)
times <- seq(0, 100)
out <- ode(y, times, model, parms)
plot(out)