Dear useRs,

I have written an ecological model, based on the epidemiology SIR model.
I've been trying to simulate it in R.
However, I can't simulate it properly.
Two guesses: my script isn't right; I'm not setting the parameters properly

I have uploaded an image to the model here:
http://img24.imageshack.us/img24/743/imagemutr.jpg

The script I am using is as it follows:

require(simecol)

mod1 <- new("odeModel",
  main = function(time, init, parms) {
  x <- init
  p <- parms
    dx1 <- p["K"] - p["alpha"]*x[1]*x[2] - p["gamma"]*x[1]
    dx2 <- x[1]*x[2]*(p["alpha"] - p["beta"])
    dx3 <- p["beta"]*x[1]*x[2] + p["gamma"]*x[1]
    list(c(dx1, dx2, dx3))
},
times = c(from=0, to=100, by=0.1),
parms = c(K=100, alpha=0.3, gamma=0.5, beta=0.2),
init = c(S=500, V=100, R=0),
solver = "lsoda"
)

plot(sim(mod1))

Thanks in advance!
Rafael.


      
____________________________________________________________________________________
[[elided Yahoo spam]]

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to