1

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?

Ophelia
  • 157
  • 1
  • 1
  • 5
  • Please add a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) and show (in code) what you have already tried. That way you can help others to help you! – dario Feb 12 '20 at 12:17

1 Answers1

1

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)
tpetzoldt
  • 5,338
  • 2
  • 12
  • 29