acceptProposal: Determine if a Metropolis–Hastings step should be accepted

Description Usage Arguments Details Value Examples

Description

acceptProposal is a utility function to determine if a proposal should be accepted in a Metropolis or Metropolis-Hastings step. This is shamelessly stolen from AcceptProposal in the overture package.

Usage

1
acceptProposal(logCurr, logProp, logCurrToProp = 0, logPropToCurr = 0)

Arguments

logCurr

log density of the target at the current value, log(P(x))

logProp

log density of the target at the proposed value, log(P(x'))

logCurrToProp

log of transition distribution from current value to proposed value, log(g(x'|x))

logPropToCurr

log of transition distribution from proposed value to current value, log(g(x|x'))

Details

The function uses the Metropolis choice for a Metropolis/Metropolis-Hastings sampler, which accepts a proposed value x' with probability

A(x', x) = min(1, P(x')/P(x) g(x|x')/g(x'|x))

where P(x) is the target distribution and g(x'|x) is the proposal distribution.

Value

TRUE/FALSE for whether the proposal should be accepted or rejected, respectively

Examples

1
2
3
4
curr <- rnorm(1, 0, 1)
prop <- curr + runif(1, -0.5, 0.5)
acceptProposal(logCurr = dnorm(curr, 0, 1, log = TRUE),
               logProp = dnorm(prop, 0, 1, log = TRUE))

cbdAmgen/bcgp0a documentation built on May 17, 2019, 10:01 a.m.