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).
Usage
invert_bt(observed, model, prior, custom_settings = list(), loglike = NULL)Arguments
- observed
Vector of observations. Ignored if
loglikeis notNULL.- model
Function called by log-likelihood. Must be
function(params)and return a vector equal tolength(observed)ornrow(observed). Ignored ifloglikeis notNULL.- prior
BayesianTools prior object.
- custom_settings
Nested settings list. See Details.
- loglike
Custom log likelihood function. If
NULL, usertm_loglike()with providedobservedandmodel.
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 checkingwhileloop. This is most commonly for setting a smaller iteration count than ininit.other– Miscellaneous (non-BayesianTools) settings, including:sampler– String describing which sampler to use. Default isDEzsuse_mpsrf– Use the multivariate PSRF to check convergence. Default isFALSEbecause 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 is10 * log10(n)(same asstats::acffunction).save_progress– File name for saving samples between loop iterations. IfNULL(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.