tempo_mcmc: tempo_mcmc

Description Usage Arguments

View source: R/tempo_mcmc.R

Description

MCMC sampler for the discrete-time binary state-transition model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
tempo_mcmc(
  y,
  covariates,
  beta_start,
  n_iter = 1000,
  n_burnin = 1000,
  n_chains = 3,
  n_workers = 1,
  pp_checks = c("mean", "variance"),
  beta_prior_mean = NULL,
  beta_prior_sd = NULL,
  random_effects = NULL,
  group_ids = NULL,
  sd_eps_start = NULL,
  correlated = TRUE,
  monitor_random_effects = FALSE
)

Arguments

y

dataframe; A dataframe with 3 columns: obs_id containing a unique ID for each observation; c1, the time step of the last observed 0 (or NA if a 0 was never observed); and c2, the time step of the first observed 1 (or NA if a 1 was never observed). In the case of exact observations, e.g. it is known that the even occured on day 42, c1 should be 41, and c2 should be 42.

covariates

list; A list of c covariates matrices, each of dimension [n,t], where n is the number of observations, t is the number of time steps during which state transition could take place, and c is the number of covariates. Use the function tempo_wrangle provided in this package to convert long form covariate data to the format necessary for input into tempo_mcmc.

beta_start

vector; a vector of starting values for model regression coefficients of length c + 1, where c is the number of covariates. The first value of beta_start is for the intercept, and the remaining c values correspond to the covariates in the same order as covariates.

n_iter

integer; The number of mcmc iterations per chain after any burn in. Defaults to 1000.

n_burnin

integer; The number of samplers per chain to discard as burn in. Defaults to 1000.

n_chains

integer; the number of MCMC chains to sample. Defaults to 3.

n_workers

integer; the number of parallel workers to use. Defaults to 1.

pp_checks

Character vector; one or both of "mean", "variance". Specifies the statistics for which posterior predictive checks should be run. Set to NA to prevent posterior predictive checks from being calculated.

beta_prior_mean

vector; Prior means for model regression coefficients in the the same order as beta_start. If NULL (the default) then priors means are set to 0.

beta_prior_sd

vector; Prior standard deviations for model regression coefficients in the the same order as beta_start. If NULL (the default) then priors standard deviations are set to 5. Note that standard deviations that are too restrictive (including the somewhat standard value of 1.5) can influence model fit significantly because posterior parameter magnitudes can be very large.

random_effects

vector; a vector of the names of covariates that should be modeled with group-level (random) effects. Names correspond to the names of the list elements of covariates. Use "intercept" to specify if the intercept should be modeled with random effects. For example, random_effects = c("intercept", "precipitation", "temperature") would specify that random effects should be modeled on the intercept and "precipitation" and "temperature" covariates. Defaults to NULL in which case no random effects are modeled.

group_ids

vector; If random_effects != NULL, indicies specifying to which group each row in y belongs. Defaults to NULL.

sd_eps_start

vector; a vector of starting values for random effect standard deviations. Values correspond to the items in random_effects. May be set to NULL if random_effects = NULL.

correlated

Boolean; Should correlations between random effects be modeled? Only applies if there is more than one random effect modeled. Defaults to TRUE.

monitor_random_effects

Boolean; Defaults to FALSE. Return posterior samples for group effects (model parameter eps)? Only applies when modeling random effects.


vlandau/tempo documentation built on March 18, 2020, 12:04 a.m.