Skip to contents

During Markov chain Monte Carlo a given parameter needs to be updated, the model needs to be simulated at the updated point.

Usage

smmala_update(
  simulate,
  logLikelihood = ll,
  dprior = function(x) prod(dnorm(x)),
  gradLogLikelihood = gllf(log10ParMapJac),
  gprior = function(x) (-x),
  fisherInformation = fi(log10ParMapJac),
  fisherInformationPrior = 0,
  parAcceptable = function(p) all(is.finite(p))
)

Arguments

simulate

a function that simulates the model

logLikelihood

a function that returns the log-likelihood value given the paramegter value, with simulations attached to the parameter as an attreibute (probably a closure)

dprior

a function that returns the prior density of the given parameter vector

gradLogLikelihood

any function that calculates or estimates the gradient of the log-likelihood function, for the chosen parameter mapping. Function must take one argument (the MCMC variable)

gprior

a function that returns the gradient of the log-prior distribution.

fisherInformation

a function that estimates the Fisher Information for a given MCMC variable (parMCMC).

fisherInformationPrior

a constant fisherInformation of the prior distribution (or rather, the precision of the prior)

parAcceptable

a function that can be used to reject a proposal based on the values of the parameters alone (shortcut to rejection, sans simulation)

Details

Using the simulations, and an acceptance rule, the proposed update is either accepted or rejected.

This function returns a closure smmala, with only parMCMC as it's sole argument: parProposal <- smmala(parGiven)

An optional argument to this function is parAcceptable, during sampling, when metropolis is called as the update function, and parAcceptable(parProposal) returns FALSE, then metropolis shortcuts to retrun(parGiven) without performing simulations.

This function can be used to weed out parameter combinations that would result in obviously nonsensical simulations without wasting CPU-time.

The argument fisherInformationPrior is really the precision of the prior (a constant matrix). It's role is additive to the fisherInformation and is used to regularize the final Fisher Information Matrix (makes it invertible).