simpleMH: Simple Metropolis-Hastings MCMC

Description Usage Arguments Value Examples

View source: R/simpleMH.R

Description

Simple Metropolis-Hastings MCMC

Usage

1
simpleMH(f, inits, theta.cov, max.iter, coda = FALSE, ...)

Arguments

f

function that returns a single scalar value proportional to the log probability density to sample from.

inits

numeric vector with the initial values for the parameters to estimate

theta.cov

covariance matrix of the parameters to estimate.

max.iter

maximum number of function evaluations

coda

logical. Should the samples be returned as coda::mcmc object? (defaults to FALSE)

...

further arguments passed to f

Value

Examples

1
2
3
4
5
6
p.log <- function(x) {
B <- 0.03
return(-x[1]^2/200 - 1/2*(x[2]+B*x[1]^2-100*B)^2)
}

simpleMH(p.log, inits=c(0, 0), theta.cov = diag(2), max.iter=3000)

simpleMH documentation built on May 3, 2021, 9:05 a.m.