tempo_derive: Calculate derived quantities

Description Usage Arguments Value

View source: R/tempo_derive.R

Description

This function can calulate select derived quantites using the output from tempo_mcmc() for observations chosed by the user. Derived quantities include the pmf and/or cdf of transition time, the transition probabilities for each time step (i.e. the parameter for the tvgeom distribution), the mean predicted transition time, and the standard deviation of the transition time distribution.

Usage

1
2
3
4
5
6
7
8
tempo_derive(
  draws,
  quantity,
  obs_idx,
  max_samples = 1000,
  parallelize = TRUE,
  n_cores = NULL
)

Arguments

draws

output from tempo_mcmc()

quantity

character vector; one or more of "probabilities", "pmf", "cdf", "mean", and "sd", specifying which quantities to calculate. Note that if your model included random effects, you must run tempo_mcmc() with monitor_random_effects = TRUE in order to calculate derived quantities.

obs_idx

integer vector; specifies the observations for which derived quantities will be calculated. Indices in obs_idx corespond to the rows in the observation data supplied to tempo_mcmc().

max_samples

integer; specify the number of samples for which to calculate derived quantites for each chain. Defaults to 1000. If max_samples is less than the number of MCMC samples, each chain in draws will be downsampled deterministically to size max_samples, resulting in a total of max_samples * <number of chains> samples.

parallelize

Boolean, should the function be run in parallel. Defaults to TRUE.

n_cores

Integer, number of cores to use for parallel processing. Defaults to NULL. If parallelize = TRUE, and n_corese = NULL (the dafaults), tempo_dic() will use parallel::detectCores() - 1 as the number of cores.

Value

list of posterior distributions for the derived quantities. "probabilities", "pmf", and "cdf" each return a 3D array with mcmc iterations as rows, time steps as columns, and observations along the 3rd margin. "mean" and "sd" return matrices with mcmc iterations as rows and observations as columns. All objects are returned with named dimensions. The dimension names for observations match the dimention names of the rows for matrices in the list of covariates supplied to tempo_mcmc().


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