Gelman: Calculate the Gelman & Ruben Diagnostic Ratio

Description Usage Arguments Examples

Description

Calculate the Gelman & Ruben Diagnostic Ratio

Usage

1
Gelman(x)

Arguments

x

Either a matrix or a mcmc.list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Target Distribution
df <- function(x){
   return(.7*dnorm(x, mean=2, sd=1) + .3*dnorm(x, mean=5, sd=1))
}

# Proposal distribution
rprop <- function(x){ x + runif(1, -2, 2)}
dprop <- function(x.star, x){ dunif(x.star-x, -2, 2) }

# Create chains
chain1 <- MCMC(df, start= 4, rprop, dprop, N=1000)
chain2 <- MCMC(df, start= 8, rprop, dprop, N=1000)
chain3 <- MCMC(df, start=-3, rprop, dprop, N=1000)
chain4 <- MCMC(df, start=-6, rprop, dprop, N=1000)
chains <- cbind(chain1, chain2, chain3, chain4)
Gelman(chains)

# Or using mMCMC
chains <- mMCMC(df, start=list(4,8,-3,-6), rprop, dprop, N=1000, num.chains=4)
traceplot(chains)
chains <- window(chains, 100, 1000)
Gelman(chains)

dereksonderegger/STA578 documentation built on May 15, 2019, 3:58 a.m.