mh.fun: Update function based on Metropolis-Hasting algorithm

View source: R/mcmc.R

mh.funR Documentation

Update function based on Metropolis-Hasting algorithm

Description

Proposals are made based on a (conditional) truncated Gaussian distribution at indices ind given other components.

Usage

mh.fun(cur, lb, ub, prior.fun, lik.fun, ll, ind, pmu, pcov, cond = TRUE,
  transform = FALSE, ...)

Arguments

cur

current value of the vector of parameters of which one component is to be updated.

lb

lower bounds for the parameter of interest. Default to -Inf if argument is missing.

ub

upper bounds for the parameters of interest. Default to Inf if argument is missing.

prior.fun

log prior function, a function of the parameter to update.

lik.fun

log-likelihood function, a function of the parameters to update. The user who wants to keep results of intermediate can pass them via attributes.

ll

value of the log-likelihood at cur.

ind

indices of cur to update.

pmu

proposal mean; if missing, default to random walk.

pcov

covariance matrix of the proposal for cur.

cond

logical; should updates be made conditional on other values in cur. Default to TRUE.

transform

logical; should individual updates for each parameter be performed on the unconstrained space? If TRUE, argument cond is ignored.

...

additional arguments passed to the function, currently ignored.

Value

a list with components

  • ll: value of the log-likelihood, with potential additional parameters passed as attributes;

  • cur: values of the parameters after update;

  • accept: logical indicating the proposal has been accepted (TRUE) or rejected (FALSE).


lbelzile/mgp documentation built on Aug. 5, 2023, 2:34 a.m.