GelmanRubin: Calculate the Gelman Rubin statistic

Description

Calculate the Gelman Rubin statistic

Usage

1
2
GelmanRubin(theta)
GR(theta)

Arguments

theta

A matrix containing samples from at least two chains on a parameter theta. Each chain should 2n iterations. The last n iterations will be used to calculate the statistic

Value

A list containing n, the between chain variance B, the within chain variance W, the estimated variance of the parameter vHat, and the Gelman Rubin statistic R = √{vHat/W}

References

Gelman, A. and Rubin, D.B. (1992) 'Inference from iterative simulations using multiple sequences with discussion.' Statistical Science 8, pp. 457-511

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## take four chains sampling from a normal mixture density
theta0 <- c(0,1)
theta1 <- c(3,2)
p <- 0.6
candidate <- c(0, 3)

v1 <- normMixMH(theta0, theta1, p, candidate, steps = 200)
v2 <- normMixMH(theta0, theta1, p, candidate, steps = 200)
v3 <- normMixMH(theta0, theta1, p, candidate, steps = 200)
v4 <- normMixMH(theta0, theta1, p, candidate, steps = 200)

theta<-cbind(v1,v2,v3,v4)
GelmanRubin(theta)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.