M_index_stan | R Documentation |
M index of reproductive skew using Stan to conduct Bayesian bootstrapping
M_index_stan(r, t, t0 = FALSE, samples = 2000, warmup = 1000,
chains = 2, adapt_delta = 0.9, max_treedepth = 12, refresh = 1)
r |
A vector of RS values over time period of observation (i.e., between times t0 and t). |
t |
A vector of ages at death or last census. |
t0 |
A vector of ages at first census. Defaults to zero. |
samples |
Number of MCMC samples per chain. |
warmup |
Number of warmup iterations per chain. |
chains |
Number of chains. |
adapt_delta |
A tuning parameter in Stan. See "rstan" package for more details. |
max_treedepth |
A tuning parameter in Stan. See "rstan" package for more details. |
refresh |
How often to print updates on MCMC progress. |
A Stan object "StanResults" and a data object "model_dat" are saved to the workspace. These can be used for plots and calculations. Results are also printed:
1) M. The posterior distribution of M, not accounting for diminishing RS returns to age.
2) M_age. The posterior distribution of M, accounting for diminishing RS returns to age.
3) M_raw. The posterior distribution of M_raw, not accounting for diminishing RS returns to age.
4) M_raw_age. The posterior distribution of M_raw, accounting for diminishing RS returns to age.
5) gamma The estimated elasticity of RS on exposure time.
set.seed(1)
RS = rpois(100, 5)
Age = rpois(100, 45)
M_index_stan(RS, Age)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.