Skip to contents

The geweke.ggplot function creates a Geweke diagnostic plot for MCMC chains using ggplot2. It calculates the Geweke diagnostic for segments of the MCMC chain and visualizes the Z-scores over the first iteration in each segment.

Usage

geweke.ggplot(x, frac1 = 0.1, frac2 = 0.5, nbins = 20, pvalue = 0.05)

Arguments

x

An object of class mcmc or mcmc.list. This object represents the MCMC chains for which the Geweke diagnostic will be calculated.

frac1

A numeric value specifying the fraction of the first segment of the chain to use in the Geweke diagnostic. Defaults to 0.1.

frac2

A numeric value specifying the fraction of the last segment of the chain to use in the Geweke diagnostic. Defaults to 0.5.

nbins

An integer specifying the number of segments (bins) into which the chain should be divided for the diagnostic calculation. Defaults to 20.

pvalue

A numeric value specifying the p-value for the confidence limits in the Z-score plot. Defaults to 0.05.

Value

A ggplot object that displays the Geweke diagnostic Z-scores for each segment of the MCMC chains. The plot includes horizontal lines indicating the confidence limits.

Details

The function splits the MCMC chain into segments, computes the Geweke diagnostic for each segment, and then plots the Z-scores. The Z-scores are compared against the standard normal quantiles, and segments outside the confidence limits indicate potential non-convergence.

Examples

if (FALSE) { # \dontrun{
library(coda)
data(line)
geweke_plot <- geweke.ggplot(line)
print(geweke_plot)
} # }