GelmanRubin: Gelman-Rubin convergence statistic

Description Usage Arguments Examples

View source: R/GelmanRubin.R

Description

Function to calculate the Gelman-Rubin statistic for a set of MCMC chains

Usage

1
GelmanRubin(chain.object, col = 0)

Arguments

col

If list elements are matrices or data frames instead of a single vector, this is the column of the matrix/data frame for which we calculate the statistic. Default is 0, which means list elements are already single vectors.

chain.list

List object where each element contains draws from a single MCMC chain. The number of chains is the number of items in the list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Example where list contains vectors
my.vec.list = list()
my.vec.list[[1]] = rnorm(1000, 1, 5)
my.vec.list[[2]] = rnorm(1000, 1.2, 5)
my.vec.list[[3]] = rnorm(1000, 1.05, 5)
GelmanRubin(my.vec.list)
## Example where list contains matrices
my.mat.list = list()
my.mat.list[[1]] = matrix(rnorm(10000, 1, 5), 1000, 10)
my.mat.list[[2]] = matrix(rnorm(10000, 1.2, 5), 1000, 10)
my.mat.list[[3]] = matrix(rnorm(10000, 1.05, 5), 1000, 10)
# Calculate R-hat for 3rd column of matrices
GelmanRubin(my.mat.list, col=3)

lcomm/ltools documentation built on May 20, 2019, 11:28 p.m.