Dear R-users, I am currently modifying a previously developed predator prey model and was curious if there was a way to add in a disturbance to the model (let's say at time t=100). The disturbance can be the introduction of 40 prey (N=40) and 10 predators (Pred = 10). I would like to see my model go from a state of equilibrium (up to t = 99), show this disturbance (at t = 100) and then slowly work its way back to equilibrium. Does anybody know if this could be done?
LVmod0D <- function(Time, State, Pars) { with(as.list(c(State, Pars)), { IngestPred <- rI * N * Pred GrowthN <- rG * N * (1 - N/K) MortPred <- rM * Pred dN <- GrowthN - IngestPred dPred <- IngestPred * AE - MortPred return(list(c(dN, dPred))) }) } pars <- c(rI = 0.1, rG = 0.9, rM = 0.8, AE = 0.9, K = 20) yini <- c(N = 20, Pred = 20) times <- seq(0, 200, by = 1) y(time=100)<-c(N=10, Pred=5) print(system.time) zout <- as.data.frame(lsoda(yini, y(time=100), times, LVmod0D, pars)) plot(zout[,1],zout[,2], type="l",col="black", ylim=range(0,25), xlab="time",ylab="population") points(zout[,1],zout[,3],type="l",col="red") title(main="prey (black) predator (red)") Thanks much for your help! [[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.