% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run_all_gof.R
\name{run.all.gof}
\alias{run.all.gof}
\title{Run a Battery of Goodness-of-Fit Tests at Once}
\usage{
run.all.gof(
  object,
  predicted_probs = NULL,
  X = NULL,
  tests = "all",
  G = 10,
  include_slow = FALSE,
  control = list()
)
}
\arguments{
\item{object}{A fitted binary logistic \code{\link[stats]{glm}}, or a binary
(0/1) response vector \code{y} (then supply \code{predicted_probs}).}

\item{predicted_probs}{Numeric predicted probabilities; required when
\code{object} is a \code{y} vector.}

\item{X}{Optional design matrix; lets the directed (DEF) tests run from the
\code{(y, predicted_probs)} form.}

\item{tests}{Either \code{"all"} (default) or a character vector of test names
to run (e.g. \code{c("EF","DEF.poly3","HL")}).}

\item{G}{Integer number of groups passed to the grouping tests (default 10).}

\item{include_slow}{Logical; when \code{TRUE}, also run the opt-in slow tests
(currently the le Cessie-van Houwelingen smoothing test, which builds an
n-by-n kernel matrix and is O(n^2)-O(n^3)). Default \code{FALSE}.}

\item{control}{Optional named list of per-test options (reserved).}
}
\value{
A \code{data.frame} with columns \code{Test}, \code{Family},
  \code{Statistic}, \code{df}, \code{p_value}, and \code{Note}.
}
\description{
Runs several goodness-of-fit tests for a binary logistic regression in one
call and returns one tidy \code{data.frame}, one row per test. Pass a fitted
\code{glm} to run the whole battery; pass \code{(y, predicted_probs)} to run
the tests that need only predictions. Each test is wrapped so that a failure of
one test never aborts the whole run.
}
\details{
The currently bundled tests are: \code{Pearson}, \code{Deviance},
\code{Osius-Rojek}, \code{Copas-RSS}, and \code{Information-Matrix} (the
White/Orme test) (global / standardized);
\code{HL} (Hosmer-Lemeshow deciles), \code{HL-equalwidth}, and
\code{Pigeon-Heyse} (partition); \code{EF} and \code{EF-normal} (the omnibus
Ebrahim-Farrington test with the chi-square and normal references; the normal
form reproduces the thesis simulation); \code{DEF.poly2/poly3/stukel}
and \code{Stukel} (directed); \code{Tsiatis}, \code{Xie}, and
\code{Pulkstenis-Robinson} (covariate-space); the two ensemble rows
(\code{Ensemble.Vote(3DEF)} and \code{Ensemble.Univ(3DEF+EF)}) from the Cauchy
combination test; and, when \code{include_slow = TRUE}, the opt-in slow tests:
\code{le-Cessie}-van Houwelingen smoothing, the GAM-based tests \code{HL-GAM},
\code{PR-GAM}, \code{Xie-GAM} (need \pkg{mgcv}; fit an overfit GAM for grouping),
\code{Stute-Zhu} (a cumulative-residual parametric-bootstrap test; set the
number of reps with \code{control = list("Stute-Zhu" = list(B = ...))}),
\code{eHL} (the e-value Hosmer-Lemeshow test, reported as p = min(1, 1/e)), and
\code{BAGofT} (the binary-adaptive GOF test; needs the \pkg{BAGofT} package,
\code{control = list(BAGofT = list(nsim = ...))}), and \code{Lai-Liu-HL} (Lai
& Liu's standardized-power procedure for the Hosmer-Lemeshow test, which has no
p-value: it reports the standardized power as the statistic and a randomized
accept/reject decision in the \code{Note}; target size via
\code{control = list("Lai-Liu-HL" = list(n0 = ..., k = ...))}).

Notes: \code{Tsiatis} and \code{Xie} cluster the covariate space with k-means
(a fixed internal seed, so results are reproducible and the caller's RNG is
left untouched). \code{Xie} uses the corrected degrees of freedom
\eqn{G - k/2 - 1} with \eqn{k} the number of predictors. \code{Pulkstenis-Robinson}
auto-detects the categorical covariate (any factor/character/logical, or a
numeric with at most \code{getOption("ebrahim.gof.pr.maxlev", 6)} distinct
values); it returns \code{NA} with a note when none is present.

Every bundled test reproduces the implementation used in the original thesis
simulation: \code{Osius-Rojek} and \code{Stukel} follow \pkg{LogisticDx}'s
\code{gof.glm} (Stukel via \code{statmod::glm.scoretest} when \pkg{statmod} is
installed), \code{Copas-RSS} follows \pkg{rms}'s gof residual, \code{HL} follows
\code{ResourceSelection::hoslem.test}, and the others match their standalone
reference functions; all were checked to agree numerically.
}
\examples{
set.seed(1)
n <- 500
x <- runif(n, -3, 3)
y <- rbinom(n, 1, 1 / (1 + exp(-(0.6 * x))))
fit <- glm(y ~ x, family = binomial())
run.all.gof(fit)                       # the whole battery + ensemble rows
run.all.gof(fit, tests = c("EF", "DEF.poly3", "HL"))
run.all.gof(y, fitted(fit))            # prediction-only tests

}
\seealso{
\code{\link{ef.gof}}, \code{\link{def.gof}}, \code{\link{def.ensemble.gof}}.
}
\author{
Ebrahim Khaled Ebrahim \email{ebrahimkhaled@alexu.edu.eg}
}
