mcmc: Utility functions for MCMC output analysis

Description Usage Arguments Details Author(s) References Examples

Description

Returns the mean, the standard deviation of the mean, and a sequence of partial means of the input vector or matrix.

Usage

1
2
3
4
mcmcMean(x, sd = TRUE)
mcmcMeans(x, sd = TRUE)
mcmcSD(x)
ergMean(x, m = 1)

Arguments

x

vector or matrix containing the output of a Markov chain Monte Carlo simulation.

sd

logical: should an estimate of the Monte Carlo standard deviation be reported?

m

ergodic means are computed for i in m:NROW(x)

Details

The argument x is typically the output from a simulation. If a matrix, rows are considered consecutive simulations of a target vector. In this case means, standard deviations, and ergodic means are returned for each column. The standard deviation of the mean is estimated using Sokal's method (see the reference). mcmcMeans is an alias for mcmcMean.

Author(s)

Giovanni Petris GPetris@uark.edu

References

P. Green (2001). A Primer on Markov Chain Monte Carlo. In Complex Stochastic Systems, (Barndorff-Nielsen, Cox and Kl\"uppelberg, eds.). Chapman and Hall/CRC.

Examples

1
2
3
4
5
6
x <- matrix(rexp(1000), nc=4)
dimnames(x) <- list(NULL, LETTERS[1:NCOL(x)])
mcmcSD(x)
mcmcMean(x)
em <- ergMean(x, m = 51)
plot(ts(em, start=51), xlab="Iteration", main="Ergodic means")

Example output

         A          B          C          D 
0.05791186 0.06034600 0.05941779 0.06943281 
     A        B        C        D   
  0.9366   0.9688   1.0260   1.0400 
 (0.0579) (0.0603) (0.0594) (0.0694)

dlm documentation built on May 2, 2019, 4:58 p.m.