geweke_test: Geweke convergence test

View source: R/plot_diagnostics.R

geweke_testR Documentation

Geweke convergence test

Description

Performs Geweke's convergence diagnostic, comparing the mean of the first portion of a chain to the last portion. It is a within-chain diagnostic, so on a multi-chain fit it is computed for each chain separately.

Usage

geweke_test(fit, frac1 = 0.1, frac2 = 0.5, pars = NULL)

## S3 method for class 'tulpa_geweke'
print(x, ...)

Arguments

fit

A tulpa_fit object.

frac1

Fraction of each chain for the first window (default: 0.1).

frac2

Fraction of each chain for the second window (default: 0.5). Both lie in ⁠(0, 1)⁠ and the windows may not overlap: frac1 + frac2 <= 1.

pars

Character vector of parameter names (default: all main params).

x

A tulpa_geweke result.

...

Ignored.

Details

The Geweke test computes a z-score comparing the means of early and late portions of a chain. Large z-scores (|z| > 2) indicate the chain has not converged. The chains are never pooled: concatenated, the "first" window would come from the first chain and the "last" from another, which compares two chains rather than a chain's start with its end (use diagnostics() for the between-chain R-hat). A parameter that is constant within a chain has an undefined z-score, reported as NA.

Value

A data frame of class tulpa_geweke with columns chain, parameter, z_score and p_value, one row per chain and parameter.

See Also

diagnostics(), check_diagnostics()

Examples


set.seed(123)
df <- data.frame(x = rnorm(60))
df$y <- rpois(60, exp(0.5 + 0.3 * df$x))
fit <- tulpa(y ~ x, data = df, family = "poisson", mode = "hmc",
             control = list(n_iter = 500L, warmup = 250L, n_chains = 2L,
                            seed = 1L))
geweke_test(fit)



tulpa documentation built on Oct. 19, 2026, 5:09 p.m.