Skip to contents

Sample from the target distribution using MCMC

Usage

run_mcmc(
  data,
  is_missing = FALSE,
  allow_relatedness = TRUE,
  thin = 1,
  burnin = 10000,
  samples_per_chain = 1000,
  verbose = TRUE,
  use_message = FALSE,
  eps_pos_alpha = 1,
  eps_pos_beta = 1,
  eps_neg_alpha = 1,
  eps_neg_beta = 1,
  r_alpha = 1,
  r_beta = 1,
  mean_coi_shape = 0.1,
  mean_coi_scale = 10,
  max_eps_pos = 2,
  max_eps_neg = 2,
  max_coi = 40,
  num_chains = 1,
  num_cores = 1,
  pt_chains = 1,
  pt_grad = 1,
  pt_num_threads = 1,
  adapt_temp = TRUE,
  pre_adapt_steps = 25,
  temp_adapt_steps = 25,
  max_initialization_tries = 10000
)

Arguments

data

Data to be used in MCMC, as generated by the load_*_data functions

is_missing

Boolean matrix indicating whether the observation should be treated as missing data and ignored. Number of rows equals the number of loci, number of columns equals the number samples. Alternatively, the user may pass in FALSE if no data should be considered missing.

allow_relatedness

Bool indicating whether or not to allow relatedness within host

thin

Positive Integer. How often to sample from mcmc, 1 means do not thin

burnin

Positive Integer. Number of MCMC samples to discard as burnin

samples_per_chain

Positive Integer. Number of samples to take after burnin

verbose

Logical indicating if progress is printed

use_message

Logical indicating if progress is printed using message or print

eps_pos_alpha

Positive Numeric. Alpha parameter in Beta distribution for eps_pos prior

eps_pos_beta

Positive Numeric. Beta parameter in Beta distribution for eps_pos prior

eps_neg_alpha

Positive Numeric. Alpha parameter in Beta distribution for eps_neg prior

eps_neg_beta

Positive Numeric. Beta parameter in Beta distribution for eps_neg prior

r_alpha

Positive Numeric. Alpha parameter in Beta distribution for relatedness prior

r_beta

Positive Numeric. Beta parameter in Beta distribution for relatedness prior

mean_coi_shape

shape parameter for gamma hyperprior on mean COI

mean_coi_scale

scale parameter for gamma hyperprior on mean COI

max_eps_pos

Numeric. Maximum allowed value for eps_pos

max_eps_neg

Numeric. Maximum allowed value for eps_neg

max_coi

Positive Numeric. Maximum allowed complexity of infection

num_chains

Total number of chains to run, possibly simultaneously

num_cores

Total OMP parallel threads to use to run chains. num_cores * pt_num_threads should not exceed the number of cores available on your system.

pt_chains

Total number of chains to run with parallel tempering or a vector containing the temperatures that should be used for parallel tempering.

pt_grad

Power to raise parallel tempering chains to. A value of 1 results in evenly distributed temperatures between [0,1], below 1 will bias towards 1 and above 1 will bias towards 0. Only used if pt_chains is a single value (i.e. not a vector).

pt_num_threads

Total number of OMP parallel threads to be used to process parallel tempered chains num_cores * pt_num_threads should not exceed the number of cores available on your system.

adapt_temp

Logical indicating whether or not to adapt the parallel tempering temperatures. If TRUE, the temperatures will be adapted during the burnin period, starting after pre_adapt_steps steps. The adaptation will occur every temp_adapt_steps steps until burnin is complete. The range of temperatures will remain the same as specified by pt_chains.

pre_adapt_steps

Number of steps to take before starting to adapt the parallel tempering temperatures. Only used if adapt_temp is TRUE.

temp_adapt_steps

Number of steps to take between temperature adaptation steps. Only used if adapt_temp is TRUE.

max_initialization_tries

Number of times to try to initialize the chain before giving up