# GelmanRubin: function for monitoring convergence of Markov chain In Scopia/StatComp18053: generating and monitoring convergence of Markov chain and permutation test for equal distribution

## Description

This function use the Gelman-Rubin method to monitor convergence of Markov chains.

## Usage

 `1` ```GelmanRubin(psi) ```

## Arguments

 `psi` the statistic for chain of X

## Details

user should provide the statistic psi(X)

## References

Statistic computing with R. Maria L. Rizzo

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```## Not run: lden=dcauchy sigma=3 M4=cumsum((MC4=Metropolis(dist=lden,N=n,sigma=sigma,print_acc=F)))/1:length(MC4) M3=cumsum((MC3=Metropolis(dist=lden,N=n,sigma=sigma,print_acc=F)))/1:length(MC3) M2=cumsum((MC2=Metropolis(dist=lden,N=n,sigma=sigma,print_acc=F)))/1:length(MC2) M1=cumsum((MC1=Metropolis(dist=lden,N=n,sigma=sigma,print_acc=F)))/1:length(MC1) psi=rbind(M1,M2,M3,M4) plot((R=sapply(1:2000,function(i)GelmanRubin(psi[,1:i]))), main="R value of Gelman-Rubin method",ylim=c(1,2)) ## End(Not run) ```

Scopia/StatComp18053 documentation built on May 22, 2019, 2:44 p.m.