# define a basic population
nstage <- 5
popmat <- matrix(0, nrow = nstage, ncol = nstage)
popmat[reproduction(popmat, dims = 4:5)] <- c(10, 20)
popmat[transition(popmat)] <- c(0.25, 0.3, 0.5, 0.65)
# define a dynamics object
dyn <- dynamics(popmat)
# simulate with the default updater
sims <- simulate(dyn, nsim = 1000)
# calculate expected minimum population size
emps(sims)
# calculate expected minimum population size for 4 and 5 year
# olds only
emps(sims, subset = 4:5)
# calculate expected minimum population size but ignore first 10 years
emps(sims, times = 11:51)
# calculate expected minimum population size based on median
emps(sims, fun = median)
Run the code above in your browser using DataLab