Description Usage Arguments Value Examples

View source: R/simulate_populations.R

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.

1 2 3 4 5 6 7 8 9 10 11 | ```
autocorr_sim(
timesteps,
start,
survPhi,
fecundPhi,
survMean,
survSd,
fecundMean,
fecundSd,
replicates
)
``` |

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

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.

1 2 3 4 | ```
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 38 22 200 200 30 0.3 0.1
2: 2 1 1 60 200 30 0.3 0.1
3: 3 0 0 2 200 30 0.3 0.1
4: 4 0 0 0 200 30 0.3 0.1
5: 5 0 0 0 200 30 0.3 0.1
6: 6 0 0 0 200 30 0.3 0.1
survMean survSd fecundMean fecundSd est_surv est_fecund
1: 0.2 0.5 1.1 0.5 0.11000000 1.727273
2: 0.2 0.5 1.1 0.5 0.01666667 1.000000
3: 0.2 0.5 1.1 0.5 0.00000000 NaN
4: 0.2 0.5 1.1 0.5 NaN NaN
5: 0.2 0.5 1.1 0.5 NaN NaN
6: 0.2 0.5 1.1 0.5 NaN NaN
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.