# 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 quasi-extinction risk at a threshold population size
# of 100 individuals
pr_extinct(sims, threshold = 100)
# repeat previous but focused on 4 and 5 year olds only
pr_extinct(sims, threshold = 100, subset = 4:5)
# repeat previous but ignore first 10 years
pr_extinct(sims, threshold = 100, times = 11:51)
Run the code above in your browser using DataLab