Use samplers from the BayesianTools package to fit models to data. Like invert.auto, this will continue to run until convergence is achieved (based on Gelman diagnostic) and the result has enough samples (as specified by the user; see Details).

invert_bt(observed, model, prior, custom_settings = list(),
  loglike = NULL)

Arguments

observed

Vector of observations. Ignored if loglike is not NULL.

model

Function called by log-likelihood. Must be function(params) and return a vector equal to length(observed) or nrow(observed). Ignored if loglike is not NULL.

prior

BayesianTools prior object.

custom_settings

Nested settings list. See Details.

loglike

Custom log likelihood function. If NULL, use rtm_loglike with provided observed and model.

Details

custom_settings is a list of lists, containing the following:

  • common -- BayesianTools settings common to both the initial and subsequent samples.

  • init -- BayesianTools settings for just the first round of sampling. This is most common for the initial number of iterations, which is the minimum expected for convergence.

  • loop -- BayesianTools settings for iterations inside the convergence checking while loop. This is most commonly for setting a smaller iteration count than in init.

  • other -- Miscellaneous (non-BayesianTools) settings, including:

    • sampler -- String describing which sampler to use. Default is DEzs

    • use_mpsrf -- Use the multivariate PSRF to check convergence. Default is FALSE because it may be an excessively conservative diagnostic.

    • min_samp -- Minimum number of samples after burnin before stopping. Default is 5000.

    • max_iter -- Maximum total number of iterations. Default is 1e6.

    • lag.max -- Maximum lag to use for autocorrelation normalization. Default is 10 * log10(n) (same as stats::acf function).

    • save_progress -- File name for saving samples between loop iterations. If NULL (default), do not save progress samples.

    • threshold -- Threshold for Gelman PSRF convergence diagnostic. Default is 1.1.

    • verbose_loglike -- Diagnostic messages in log likelihood output. Default is TRUE.

See the BayesianTools sampler documentation for what can go in the BayesianTools settings lists.