Assume and a current state with , . The unnormalized posterior density isThus the log-posterior, up to an additive constant, is the log-likelihood plus the beta distribution and exponential distribution log prior densities. The exponential distribution rate is , since is its mean. [ref]
https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Beta.html. Official R documentation: dbeta arguments and logarithmic density output
[ref]https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Exponential.html. Official R documentation: dexp rate parameter and mean equal to inverse rate
Choose a symmetric joint random-walk Metropolis algorithm proposal: and , for independent standard normal distribution draws. Its scale depends only on fixed hyperparameters, so forward and reverse proposal probability density functions agree. Reject immediately outside ; otherwise accept with Metropolis–Hastings acceptance probabilityThe following function makes exactly one proposal, with rejection retaining both old parameters:
MHstep <- function(x, p, beta, a, b, mu) {
p_new <- rnorm(1, mean = p, sd = 0.1)
beta_new <- rnorm(1, mean = beta, sd = mu / 2)
if (p_new <= 0 || p_new >= 1 || beta_new <= 0)
return(list(p = p, theta = beta))
logpost <- function(pp, bb) {
ll_f(pp, bb, x) + dbeta(pp, a, b, log = TRUE) +
dexp(bb, rate = 1 / mu, log = TRUE)
}
logA <- logpost(p_new, beta_new) - logpost(p, beta)
if (log(runif(1)) <= min(0, logA)) {
p <- p_new
beta <- beta_new
}
list(p = p, theta = beta)
}The returned field
theta contains the updated value of beta. The original PDF really asks for p and theta, although no parameter is defined in this question. This choice preserves its literal interface while making the intended second parameter explicit. A caller therefore advances with state <- MHstep(x, p, beta, a, b, mu), p <- state$p, and beta <- state$theta.The proposal is an unrestricted symmetric normal distribution followed by rejection outside the support. Repeatedly drawing until a valid proposal appears would instead truncate and renormalize the proposal, requiring a proposal-density correction. The code uses immediate rejection and needs no such correction. The displayed scales are valid fixed choices; practical efficiency can be improved using a separate tuning phase.
Articles by others on the same topic
There are currently no matching articles.