.run_pilot_chain {bayesSSM}R Documentation

Run Pilot Chain for Posterior Estimation

Description

Run Pilot Chain for Posterior Estimation

Usage

.run_pilot_chain(
  y,
  pilot_m,
  pilot_n,
  pilot_reps,
  init_fn,
  transition_fn,
  log_likelihood_fn,
  log_priors,
  proposal_sd,
  obs_times = NULL,
  algorithm = c("SISAR", "SISR", "SIS"),
  resample_fn = c("stratified", "systematic", "multinomial"),
  param_transform = NULL,
  pilot_init_params = NULL,
  verbose = FALSE,
  ...
)

Arguments

y

A numeric vector of observations.

pilot_m

An integer specifying the number of iterations for the pilot chain.

pilot_n

An integer specifying the number of particles for the particle filter.

pilot_reps

An integer specifying the number of repetitions for the pilot run.

init_fn

A function to initialize the state space model.

transition_fn

A function that defines the state transition dynamics in the state space model.

log_likelihood_fn

A function that computes the log-likelihood of the observations given the model parameters.

log_priors

A list of functions representing the log-priors for each model parameter.

proposal_sd

A numeric vector specifying the standard deviations for the random walk proposal distribution for each parameter.

obs_times

A numeric vector of observation times. If not provided, the function assumes observations are available at every time step.

algorithm

A character string specifying the particle filter algorithm to use. One of "SISAR", "SISR", or "SIS". Default is "SISAR".

resample_fn

A character string specifying the resampling method to use. One of "stratified", "systematic", or "multinomial". Default is "stratified".

param_transform

A character vector specifying the parameter transformations when proposing parameters using a random walk. Currently only supports "log" for log-transformation and "identity" for no transformation. Default is 'NULL', which correspond to no transformation ("identity).

pilot_init_params

A numeric vector of initial parameter values. If 'NULL', the default is a vector of ones. Default is 'NULL'.

...

Additional arguments passed to the particle filter function.

Details

This function runs a pilot chain to estimate the posterior mean and covariance of the model parameters using a particle filter. The chain is run for 'pilot_m' iterations, with each iteration proposing new parameters and evaluating their likelihood and prior. The chain is then used to estimate the posterior mean and covariance, which are used to tune the number of particles for the Particle Marginal Metropolis Hastings (PMMH) algorithm.

Value

A list containing:

pilot_theta_mean

A numeric vector of the posterior mean of the parameters.

pilot_theta_cov

A matrix of the posterior covariance (or variance if only one parameter).

target_N

The estimated target number of particles for the PMMH algorithm.

pilot_theta_chain

A matrix containing the chain of parameter values throughout the pilot run.

pilot_loglike_chain

A vector containing the log-likelihood values associated with each iteration of the pilot chain.


[Package bayesSSM version 0.5.0 Index]