metropolis {ProbBayes} | R Documentation |
Metropolis sampling of a continuous distribution
Description
Implements Metropolis sampling for an arbitrary continuous probability distribution
Usage
metropolis(logpost, current, C, iter, ...)
Arguments
logpost |
function definition of the log probability function |
current |
starting value of algorithm |
C |
half-width of proposal interval |
iter |
number of iterations |
... |
other inputs needed in logpost function |
Value
S |
vector of simulated values |
accept_rate |
acceptance rate of algorithm |
Author(s)
Jim Albert
Examples
lpost <- function(theta, s){
dnorm(s$ybar, theta, s$se, log = TRUE) +
dcauchy(theta, s$loc, s$scale, log = TRUE)
}
s <- list(ybar = 20,
se = 0.4,
loc = 10,
scale = 2)
post <- metropolis(lpost, 10, 20, 100, s)
[Package ProbBayes version 1.1 Index]