conv.diag {BANOVA} | R Documentation |

## Function to display the convergence diagnostics

### Description

The Geweke diagnostic and the Heidelberg and Welch diagnostic are reported. These two convergence diagnostics are calculated based on only a single MCMC chain. Both diagnostics require a single chain and may be applied with any MCMC method. The functions `geweke.diag`

, `heidel.diag`

in **coda** package is used to compute this diagnostic.

Geweke's convergence diagnostic is calculated by taking the difference between the means from the first `n_A`

iterations and the last `n_B`

iterations. If the ratios `n_A/n`

and `n_B/n`

are fixed and `nA +nB < n`

, then by the central limit theorem, the distribution of this diagnostic approaches a standard normal as `n`

tends to infinity. In our package, `n_A= .2*n`

and `n_B= .5*n`

.

The Heidelberg and Welch diagnostic is based on a test statistic to accept or reject the null hypothesis that the Markov chain is from a stationary distribution. The present package reports the stationary test.The convergence test uses the Cramer-von Mises statistic to test for stationary. The test is successively applied on the chain. If the null hypothesis is rejected, the first 10% of the iterations are discarded and the stationarity test repeated. If the stationary test fails again, an additional 10% of the iterations are discarded and the test repeated again. The process continues until 50% of the iterations have been discarded and the test still rejects. In our package, `eps = 0.1, pvalue = 0.05`

are used as parameters of the function `heidel.diag`

.

### Usage

```
conv.diag(x)
```

### Arguments

`x` |
the object from BANOVA.* |

### Value

`conv.diag`

returns a list of two diagnostics:

`sol_geweke` |
The Geweke diagnostic |

`sol_heidel` |
The Heidelberg and Welch diagnostic |

### References

Plummer, M., Best, N., Cowles, K. and Vines K. (2006) *CODA: Convergence Diagnosis and Output Analysis for MCMC*, R News, Vol 6, pp. 7-11.

Geweke, *J. Evaluating the accuracy of sampling-based approaches
to calculating posterior moments*, In *Bayesian Statistics 4*
(ed JM Bernado, JO Berger, AP Dawid and AFM Smith). Clarendon Press,
Oxford, UK.

Heidelberger, P. and Welch, PD. (1981)
*A spectral method for confidence interval generation and run length control in simulations*, Comm. ACM. Vol. 24, No.4, pp. 233-245.

Heidelberger, P. and Welch, PD. (1983)
*Simulation run length control in the
presence of an initial transient*, Opns Res., Vol.31, No.6, pp. 1109-44.

Schruben, LW. (1982)
*Detecting initialization bias in simulation experiments*,
Opns. Res., Vol. 30, No.3, pp. 569-590.

### Examples

```
data(goalstudy)
library(rstan)
res1 <- BANOVA.run(bid~progress*prodvar, model_name = "Normal", data = goalstudy,
id = 'id', iter = 100, thin = 1)
conv.diag(res1)
# might need pairs() to confirm the convergence
```

*BANOVA*version 1.2.1 Index]