Essentially a loop of unstructured_pop, this function simulates a population with temporally autocorrelated vital rates for every combination of parameters you specify, with as many replicates as desired. It also estimates the sample mean survival and fertility for each simulated population. Please be advised that this function can be very computationally intensive if you provide many possible parameter values and/or ask for many replicates.

autocorr_sim(
  timesteps,
  start,
  survPhi,
  fecundPhi,
  survMean,
  survSd,
  fecundMean,
  fecundSd,
  replicates
)

Arguments

timesteps

The number of timesteps you want to simulate. Individuals are added and killed off every timestep according to the survival and fertility rates. Can be a scalar or a vector of values to loop over.

start

The starting population size. Can be a scalar or vector.

survPhi

The temporal autocorrelation of survival. 0 is white noise (uncorrelated), positive values are red noise (directly correlated) and negative values are blue noise (inversely correlated). Can be a scalar or a vector.

fecundPhi

The temporal autocorrelation of fecundity. As above.

survMean

The mean survival from timestep to timestep. Must be a value between 0 (all individuals die) and 1 (all individuals live). Can be a scalar or a vector.

survSd

The standard deviation of the survival from timestep to timestep. Must be a value between 0 and 1. Can be a scalar or a vector.

fecundMean

The mean fertility: mean offspring produced by each individual per timestep. Can be a scalar or a vector.

fecundSd

The standard deviation of the fertility. Can be a scalar or a vector of values.

replicates

How many replicates you would like of each possible combination of parameters.

Value

A list of data frames, each with fourteen variables: timestep, newborns (new individuals added this timestep), survivors (individuals alive last year who survived this timestep), population (total individuals alive), growth (the increase or decrease in population size from last year), estimated survival in the timestep, estimated fecundity in the timestep, and the seven parameters used to generate the simulation.

Examples

survival_range <- autocorr_sim(timesteps = 30, start = 200, survPhi = 0.3, fecundPhi = 0.1, survMean = c(0.2, 0.3, 0.4, 0.5, 0.6), survSd = 0.5, fecundMean = 1.1, fecundSd = 0.5, replicates = 50) head(survival_range[[1]])
#> timestep newborns survivors population start timesteps survPhi fecundPhi #> 1: 1 410 150 200 200 30 0.3 0.1 #> 2: 2 266 121 560 200 30 0.3 0.1 #> 3: 3 74 51 387 200 30 0.3 0.1 #> 4: 4 54 31 125 200 30 0.3 0.1 #> 5: 5 16 17 85 200 30 0.3 0.1 #> 6: 6 44 20 33 200 30 0.3 0.1 #> survMean survSd fecundMean fecundSd est_surv est_fecund #> 1: 0.2 0.5 1.1 0.5 0.7500000 2.7333333 #> 2: 0.2 0.5 1.1 0.5 0.2160714 2.1983471 #> 3: 0.2 0.5 1.1 0.5 0.1317829 1.4509804 #> 4: 0.2 0.5 1.1 0.5 0.2480000 1.7419355 #> 5: 0.2 0.5 1.1 0.5 0.2000000 0.9411765 #> 6: 0.2 0.5 1.1 0.5 0.6060606 2.2000000