Learn R Programming

bssm (version 1.0.0)

run_mcmc.ssm_nlg: Bayesian Inference of non-linear state space models

Description

Methods for posterior inference of states and parameters.

Usage

# S3 method for ssm_nlg
run_mcmc(
  model,
  iter,
  nsim,
  output_type = "full",
  mcmc_type = "da",
  sampling_method = "bsf",
  burnin = floor(iter/2),
  thin = 1,
  gamma = 2/3,
  target_acceptance = 0.234,
  S,
  end_adaptive_phase = TRUE,
  n_threads = 1,
  seed = sample(.Machine$integer.max, size = 1),
  max_iter = 100,
  conv_tol = 1e-08,
  iekf_iter = 0,
  ...
)

Arguments

model

Model model.

iter

Number of MCMC iterations.

nsim

Number of state samples per MCMC iteration. Ignored if mcmc_type is "approx" or "ekf".

output_type

Either "full" (default, returns posterior samples of states alpha and hyperparameters theta), "theta" (for marginal posterior of theta), or "summary" (return the mean and variance estimates of the states and posterior samples of theta).

mcmc_type

What MCMC algorithm to use? Possible choices are "pm" for pseudo-marginal MCMC, "da" for delayed acceptance version of PMCMC (default), "approx" for approximate inference based on the Gaussian approximation of the model, "ekf" for approximate inference using extended Kalman filter, or one of the three importance sampling type weighting schemes: "is3" for simple importance sampling (weight is computed for each MCMC iteration independently), "is2" for jump chain importance sampling type weighting, or "is1" for importance sampling type weighting where the number of particles used for weight computations is proportional to the length of the jump chain block.

sampling_method

If "psi", \(\psi\)-auxiliary particle filter is used for state sampling. If "ekf", particle filter based on EKF-proposals are used. If "bsf" (default), bootstrap filter is used.

burnin

Length of the burn-in period which is disregarded from the results. Defaults to iter / 2.

thin

Thinning rate. Defaults to 1. Increase for large models in order to save memory. For IS-corrected methods, larger value can also be statistically more effective. Note: With output_type = "summary", the thinning does not affect the computations of the summary statistics in case of pseudo-marginal methods.

gamma

Tuning parameter for the adaptation of RAM algorithm. Must be between 0 and 1 (not checked).

target_acceptance

Target acceptance ratio for RAM. Defaults to 0.234.

S

Initial value for the lower triangular matrix of RAM algorithm, so that the covariance matrix of the Gaussian proposal distribution is \(SS'\). Note that for some parameters (currently the standard deviation and dispersion parameters of bsm_ng models) the sampling is done for transformed parameters with internal_theta = log(theta).

end_adaptive_phase

If TRUE (default), $S$ is held fixed after the burnin period.

n_threads

Number of threads for state simulation.

seed

Seed for the random number generator.

max_iter

Maximum number of iterations used in Gaussian approximation.

conv_tol

Tolerance parameter used in Gaussian approximation.

iekf_iter

If iekf_iter > 0, iterated extended Kalman filter is used with iekf_iter iterations in place of standard EKF. Defaults to zero.

...

Ignored.