| ebrahim.gof-package | R Documentation |
A unified toolbox of goodness-of-fit and calibration tests for binary
logistic regression, callable in a single line via run.all.gof.
The package is aimed particularly at sparse data, where the classical
Hosmer–Lemeshow test loses power, and at penalized fits, where it is
not merely weak but invalid.
The battery is the place to start; the table below is for when you already know something about what you are looking for.
run.all.gof — runs the
whole battery and groups the results by the departure each test detects.
ef.gof — the omnibus
Ebrahim–Farrington test, which groups automatically and needs no model
object.
edge.gof
— spends its few degrees of freedom on the smooth directions where
structured misfit concentrates.
cdef.gof —
the covariate-space directed test.
edges.gof — a
Cauchy combination over the directed bases, which pays little for the
directions that turn out to be empty.
legoft
— weights fixed offline and shipped frozen, so nothing is retrained when
you call it; legoft.localize then says which domain of
evidence carries the misfit, with familywise error control.
deepgof1 —
a pretrained convolutional statistic whose level comes from your own
parametric bootstrap rather than from the network; its map shows where
the misfit lies.
localize.external for
frozen predictions on validation data, localize.gof for a fitted
logistic model — names the intercept, slope, link or covariate part of the
misfit with familywise error control, and the update the highest one calls for.
calm.gof for a closed-form
reference from a single fit, or shrink.gof for the same
correction referred to a prepivoting bootstrap. Under a penalty the usual
chi-squared references are wrong, not just conservative.
gof.features turns a fit into a
feature vector and deploy.gof applies a scorer to it.
run.all.gof also runs, in one call, a wide range of classical
and modern tests — Hosmer–Lemeshow, McCullagh, Osius–Rojek,
le Cessie–van Houwelingen, Stute–Zhu, the binary-adaptive BAGofT test,
and the givitiR calibration test. Each aggregated test is obtained from
its own package (where installed) and is attributed to its authors; these are
provided for head-to-head comparison, not claimed as original to this package.
gof_install_suggests installs the optional packages they need.
gof_demo is a bundled example dataset with a documented,
reproducible misfit for illustrating the battery.
Each of the author's tests has a paper behind it. Run
citation("ebrahim.gof") for the current references; they are kept
there rather than duplicated here, because several are moving from preprint
to journal.
Maintainer: Ebrahim Khaled Ebrahim ebrahimkhaled@alexu.edu.eg (ORCID)
Other contributors:
Jiawei Zhang (author of the BAGofT package code adapted in R/bagoft_fast.R) [contributor, copyright holder]
Jie Ding (author of the BAGofT package code adapted in R/bagoft_fast.R) [contributor, copyright holder]
Yuhong Yang (author of the BAGofT package code adapted in R/bagoft_fast.R) [contributor, copyright holder]
The vignettes
vignette("ebrahim-gof-toolbox", package = "ebrahim.gof") and
vignette("extensions", package = "ebrahim.gof").
set.seed(1)
n <- 200
x <- rnorm(n)
y <- rbinom(n, 1, plogis(0.3 + 0.9 * x))
fit <- glm(y ~ x, family = binomial())
# the omnibus test on the fitted probabilities
ef.gof(y, fitted(fit))
# the directed test, when misfit is expected in the calibration shape
edge.gof(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.