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
## 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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Bolstad2)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Bolstad2/GelmanRubin.Rd_%03d_medium.png", width=480, height=480)
> ### Name: GelmanRubin
> ### Title: Calculate the Gelman Rubin statistic
> ### Aliases: GelmanRubin GR
>
> ### ** Examples
>
> ## 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)
1.02057914682519
>
>
>
>
>
> dev.off()
null device
1
>