% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{geweke_diag}
\alias{geweke_diag}
\title{Geweke's MCMC Convergence Diagnostic}
\usage{
geweke_diag(chain, frac1 = 0.1, frac2 = 0.5)
}
\arguments{
\item{chain}{A numeric matrix or data frame where columns correspond to parameters and rows to iterations,
or a numeric vector for a single parameter.}

\item{frac1}{Fraction of the chain to take from the beginning (default: 0.1).}

\item{frac2}{Fraction of the chain to take from the end (default: 0.5).}
}
\value{
A data frame containing:
  \item{parameter}{Name of the parameter.}
  \item{mean_first}{Mean of the initial fraction of iterations.}
  \item{mean_last}{Mean of the final fraction of iterations.}
  \item{z_score}{Geweke z-statistic.}
  \item{p_value}{Two-sided p-value for equality of means.}
  \item{converged}{Logical indicating whether convergence is supported at alpha = 0.05 level.}
}
\description{
Computes Geweke's convergence diagnostic for MCMC chains by comparing the sample means of
early and late parts of the Markov chain.
}
\details{
Geweke's convergence diagnostic tests for equality of the mean of early simulations
(default first 10\%) and the mean of later iterations (default last 50\%). Under the null hypothesis
of convergence, the test statistic follows a standard normal distribution.
}
\examples{
set.seed(123)
sample_chain <- matrix(rnorm(1000), ncol = 2, dimnames = list(NULL, c("param1", "param2")))
diag_res <- geweke_diag(sample_chain)
print(diag_res)
}
\references{
Geweke, J. (1992). Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments.
\emph{Bayesian Statistics}, 4, 169-193.

Pan, Z., & Balakrishnan, N. (2010). Multiple-Steps Step-Stress Accelerated Degradation Modeling Based on Wiener and Gamma Processes.
\emph{Communications in Statistics - Simulation and Computation}, 39(7), 1384-1402. \doi{10.1080/03610918.2010.496060}
}
