GRstats: Compute Gelman and Rubin's convergence diagnostics from...

View source: R/GRstats.R

GRstatsR Documentation

Compute Gelman and Rubin's convergence diagnostics from multicore BayesX models.

Description

This function takes a fitted bayesx object estimated with multiple chains/cores and computes the Gelman and Rubin's convergence diagnostic of the model parameters using function gelman.diag provided in package coda.

Usage

GRstats(object, term = NULL, ...)

Arguments

object

an object of class "bayesx", returned from the model fitting function bayesx using the multiple chain or core option.

term

character or integer. The term for which the diagnostics should be computed, see also function samples.

...

arguments passed to function gelman.diag.

Value

An object returned from gelman.diag.

Author(s)

Nikolaus Umlauf, Thomas Kneib, Stefan Lang, Achim Zeileis.

See Also

bayesx, gelman.diag, samples.

Examples

## Not run: 
## generate some data
set.seed(111)
n <- 500

## regressors
dat <- data.frame(x = runif(n, -3, 3), z = runif(n, -3, 3),
   w = runif(n, 0, 6), fac = factor(rep(1:10, n/10)))

## response
dat$y <- with(dat, 1.5 + sin(x) + cos(z) * sin(w) +
   c(2.67, 5, 6, 3, 4, 2, 6, 7, 9, 7.5)[fac] + rnorm(n, sd = 0.6))

## estimate model
b <- bayesx(y ~ sx(x) + sx(z, w, bs = "te") + fac,
   data = dat, method = "MCMC", chains = 3)

## obtain Gelman and Rubin's convergence diagnostics
GRstats(b, term = c("sx(x)", "sx(z,w)"))
GRstats(b, term = c("linear-samples", "var-samples"))

## of all parameters
GRstats(b, term = c("sx(x)", "sx(z,w)",
  "linear-samples", "var-samples"))

## End(Not run)

R2BayesX documentation built on Oct. 20, 2023, 3:01 p.m.