% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ordinalGOF.R
\name{ordinalGOF}
\alias{ordinalGOF}
\title{Goodness-of-Fit Test for Ordinal Regression Models}
\usage{
ordinalGOF(
  model,
  data,
  catvars = NULL,
  g = 10,
  test = c("hl", "pr.chi2", "pr.dev", "lipsitz"),
  ties = c("stata", "sorted", "equal"),
  show_table = FALSE
)
}
\arguments{
\item{model}{A fitted model object. Supported classes: \code{polr} (MASS),
\code{vglm} (VGAM), or \code{glm} (stats, binomial family).}

\item{data}{A data frame used to fit the model.}

\item{catvars}{Character vector of categorical variable names. Required only
when \code{test = "pr.chi2"} or \code{test = "pr.dev"}.}

\item{g}{Integer. Number of quantile groups (default: 10).}

\item{test}{Character. The test to perform. One of \code{"hl"} (default),
\code{"lipsitz"}, \code{"pr.chi2"}, or \code{"pr.dev"}.}

\item{ties}{Character. Tie-breaking method for grouping. One of
\code{"stata"} (default), \code{"sorted"}, or \code{"equal"}.
\code{"stata"} reproduces 'Stata's behavior.}

\item{show_table}{Logical. If \code{TRUE}, prints the observed/expected
frequency table. Default is \code{FALSE}.}
}
\value{
An object of class \code{htest} containing:
\describe{
\item{statistic}{The chi-squared test statistic.}
\item{parameter}{Degrees of freedom.}
\item{p.value}{The p-value.}
\item{method}{A character string naming the test used.}
}
}
\description{
Tests the goodness of fit for ordinal regression models, reproducing
results equivalent to 'Stata's output. Supports models from \code{polr()},
\code{vglm()}, and binary \code{glm()}.
}
\examples{
library(MASS)
data(housing, package = "MASS")
m <- polr(Sat ~ Infl + Type + Cont, data = housing, Hess = TRUE)
ordinalGOF(m, data = housing, g = 5, test = "hl", ties = "stata")

}
