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 = 100,
agemode = "elasticity",
priors = NULL
)
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. |
agemode |
Age control based on "elasticity" or "gaussianprocess". If Gaussian process is used, t and t0 must be integers, and max(t) not too big (e.g., < 90 or so). |
priors |
A 2 x 2 matrix. The first row gives the mean and sd of a normal distribution for the elasticity parameter, with default of mu=1.0, sd=0.1. The second row give the prior for the log concentration parameter, with a default of mu=0.0, sd=2.5. |
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.