M_index_stan: M index of reproductive skew using Stan to conduct Bayesian...

View source: R/M_Index_Stan.R

M_index_stanR Documentation

M index of reproductive skew using Stan to conduct Bayesian bootstrapping

Description

M index of reproductive skew using Stan to conduct Bayesian bootstrapping

Usage

M_index_stan(r, t, t0 = FALSE, samples = 2000, warmup = 1000,
  chains = 2, adapt_delta = 0.9, max_treedepth = 12, refresh = 1)

Arguments

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.

Value

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.

Examples

set.seed(1)
RS = rpois(100, 5) 
Age = rpois(100, 45)
M_index_stan(RS, Age)

ctross/SkewCalc documentation built on March 18, 2024, 7:49 a.m.