| Title: | Bias-Reduced and Penalized Generalized Estimating Equations |
|---|---|
| Description: | Fits marginal regression models for repeated or clustered responses using generalized estimating equations (GEE). Provides ordinary GEE estimators, bias-reduced and bias-corrected GEE estimators, and Jeffreys-type penalized GEE estimators for binary, count and continuous responses. Methods are described in Touloumis (2026a) <doi:10.48550/arXiv.2606.16043> and Touloumis (2026b) <doi:10.48550/arXiv.2606.16058>. |
| Authors: | Anestis Touloumis [aut, cre] (ORCID: <https://orcid.org/0000-0002-5965-1639>) |
| Maintainer: | Anestis Touloumis <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.1 |
| Built: | 2026-10-20 15:21:35 UTC |
| Source: | https://github.com/anestistouloumis/geer |
Fits marginal models for clustered or repeated responses by generalized
estimating equations (GEE; Liang and Zeger, 1986), using ordinary,
bias-reduced, or bias-corrected GEE (Touloumis, 2026a) or Jeffreys-type
penalized GEE (Touloumis, 2026b). geewa handles continuous,
binary, and count responses with a working correlation structure, and
geewa_binary handles binary responses with a working
odds-ratio structure.
Anestis Touloumis [email protected]
Liang, K.Y. and Zeger, S.L. (1986) Longitudinal data analysis using generalized linear models. Biometrika, 73, 13–22.
Touloumis, A. (2026a) Bias-reduced GEE via adjusted estimating equations, with odds-ratio extensions. arXiv preprint. doi:10.48550/arXiv.2606.16043
Touloumis, A. (2026b) Jeffreys-type penalized GEE for correlated binary data with an odds-ratio parameterization. arXiv preprint. doi:10.48550/arXiv.2606.16058
Model fitting: geewa, geewa_binary,
geer_control.
Summaries and inference: summary.geer,
vcov.geer, confint.geer,
predict.geer, tidy.geer,
glance.geer.
Model building: anova.geer, add1.geer,
step_p, step_criterion,
geecriteria.
Diagnostics: residuals.geer,
hatvalues.geer, local_influence,
runs_test, frechet_bounds_cor,
mcar_little_test, mcar_logistic_test,
mcar_homoscedasticity_test.
Other packages: emmeans-support,
marginaleffects-support.
Fits all models that differ from a fitted geer object by adding or
dropping a single term in scope, and tests each change.
## S3 method for class 'geer' add1( object, scope, test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), ... ) ## S3 method for class 'geer' drop1( object, scope, test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), ... )## S3 method for class 'geer' add1( object, scope, test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), ... ) ## S3 method for class 'geer' drop1( object, scope, test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), ... )
object |
a fitted model object of class |
scope |
a formula giving the terms to be considered for adding or dropping. |
test |
character string specifying the hypothesis test: Wald
( |
cov_type |
character string specifying the covariance matrix estimator
used for inference: one of the estimators described in
|
pmethod |
character string specifying the approximation to the null
distribution of the modified working tests: Rao-Scott ( |
... |
additional arguments passed to or from other methods. Currently unused. |
For add1(), scope must contain at least one term not in the
model, and . denotes the terms already in the model. Additions and
deletions respect marginality: a term is not dropped while a higher-order
interaction containing it remains, and an interaction is not added without
its lower-order terms. The tests are described in
anova.geer. The table also reports the correlation
information criterion (CIC) of each model, computed with cov_type;
with cov_type = "jackknife" every candidate model is therefore
refitted once per cluster.
When object was fitted with a data frame, every candidate model is
refitted to the rows of that data frame used by object, so rows
omitted because of missing values stay omitted even if the candidate model
does not use the variable concerned. For add1(), a term with missing
values in these rows is an error.
An object of class c("geer_anova", "anova", "data.frame") with one row
for the current model and one for each admissible addition or deletion, and
columns Df, CIC, Chi, and Pr(>Chi).
Rotnitzky, A. and Jewell, N.P. (1990) Hypothesis testing of regression parameters in semiparametric generalized linear models for cluster correlated data. Biometrika, 77, 485–497.
anova.geer, step_p,
geecriteria, geewa, geewa_binary.
data("respiratory", package = "geer") respiratory2 <- respiratory[respiratory$center == "C2", ] fit <- geewa( formula = status ~ baseline + treatment + gender + visit + age, family = binomial(link = "probit"), data = respiratory2, id = id, repeated = visit, corstr = "ar1" ) ## Single-term deletions drop1(fit, test = "score") ## Single-term additions add1(fit, scope = ~ . + baseline:age + visit:age + treatment:age, test = "score")data("respiratory", package = "geer") respiratory2 <- respiratory[respiratory$center == "C2", ] fit <- geewa( formula = status ~ baseline + treatment + gender + visit + age, family = binomial(link = "probit"), data = respiratory2, id = id, repeated = visit, corstr = "ar1" ) ## Single-term deletions drop1(fit, test = "score") ## Single-term additions add1(fit, scope = ~ . + baseline:age + visit:age + treatment:age, test = "score")
Computes tables of hypothesis tests for one or more fitted geer
objects, analogous to analysis of deviance tables for generalized linear
models.
## S3 method for class 'geer' anova( object, ..., test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite") )## S3 method for class 'geer' anova( object, ..., test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite") )
object |
a fitted model object of class |
... |
additional fitted model objects of class |
test |
character string specifying the hypothesis test: Wald
( |
cov_type |
character string specifying the covariance matrix estimator
used for inference: one of the estimators described in
|
pmethod |
character string specifying the approximation to the null
distribution of the modified working tests: Rao-Scott ( |
The tests are those of Rotnitzky and Jewell (1990). The Wald and score
statistics use the covariance matrix selected by cov_type. The
modified working tests compare a working statistic with a weighted sum of
independent chi-squared variables, whose weights depend on cov_type,
and pmethod selects the approximation to its distribution. The
modified working likelihood ratio test requires a working independence
structure, and both working log-likelihoods are scaled by the dispersion of
the larger model. The score tests are evaluated at the fitted means of the
smaller model with the association and dispersion parameters of the larger
model; with cov_type = "jackknife", the covariance component is the
jackknife covariance of the larger model. The small-sample estimators of
vcov.geer, such as "kauermann-carroll", are evaluated
at the same fitted means, which extends their published definitions.
With several models, the fits must use the same data and each consecutive pair must be nested. A model whose working association structure differs from that of the first model is omitted with a warning, and any other difference in the fitting settings, such as the estimation method or the handling of the dispersion, is an error.
With one model, the sequential models are refitted to the rows used by the
fit, as described in add1.geer.
An object of class c("geer_anova", "anova", "data.frame") with columns
Df, Resid. Df, Chi, and Pr(>Chi). With one model,
the terms are tested sequentially, from first to last; with several models,
each model is compared with the previous one. Resid. Df is the number
of observations minus the number of regression parameters.
Rotnitzky, A. and Jewell, N.P. (1990) Hypothesis testing of regression parameters in semiparametric generalized linear models for cluster correlated data. Biometrika, 77, 485–497.
add1.geer, drop1.geer,
step_p, geecriteria, geewa,
geewa_binary.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) ## Sequential tests of the terms anova(fit) ## Comparison of nested models fit_null <- update(fit, . ~ . - treatment) anova(fit_null, fit, test = "score")data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) ## Sequential tests of the terms anova(fit) ## Comparison of nested models fit_null <- update(fit, . ~ . - treatment) anova(fit_null, fit, test = "score")
Data from a randomized two-period crossover trial on cerebrovascular deficiency.
cerebrovascularcerebrovascular
A data frame with 134 rows and 4 columns:
integer subject identifier.
integer period identifier.
binary indicator of ECG status, 0 = abnormal and 1 = normal.
factor with levels placebo and active.
Sixty-seven subjects were enrolled in a two-period crossover trial, yielding 134 observations (two per subject). Subjects were randomly assigned to receive either placebo followed by active treatment, or active treatment followed by placebo. ECG status was classified as normal or abnormal at each period.
Jones, B. and Kenward, M.G. (1989) Design and Analysis of Cross-over Trials. Chapman and Hall, London.
data("cerebrovascular", package = "geer") str(cerebrovascular)data("cerebrovascular", package = "geer") str(cerebrovascular)
Data from a randomized clinical trial on shoulder pain after laparoscopic cholecystectomy.
cholecystectomycholecystectomy
A data frame with 246 rows and 6 columns:
integer subject identifier.
integer time identifier.
binary indicator of shoulder pain status, 0 = high pain and 1 = low pain.
factor with levels placebo and active.
factor with levels female and male.
numeric age in years.
Forty-one subjects were enrolled in a randomized clinical trial of shoulder pain after laparoscopic cholecystectomy (Jorgensen et al., 1995), yielding 246 observations (six per subject). Subjects were assigned to either the active group (with abdominal suction) or the placebo group (without abdominal suction). Shoulder pain was assessed on six occasions: morning and afternoon on each of the first three postoperative days.
Lumley, T. (1996) Generalized estimating equations for ordinal data: a note on working correlation structures. Biometrics, 52, 354–361.
Jorgensen, J.O., Gillies, R.B., Hunt, D.R., Caplehorn, J.R.M. and Lumley, T. (1995) A simple and effective way to reduce postoperative pain after laparoscopic cholecystectomy. Australian and New Zealand Journal of Surgery, 65, 466–469.
data("cholecystectomy", package = "geer") str(cholecystectomy)data("cholecystectomy", package = "geer") str(cholecystectomy)
Extracts the estimated regression coefficients from a fitted geer
object. coefficients is an alias for coef.
## S3 method for class 'geer' coef(object, ...)## S3 method for class 'geer' coef(object, ...)
object |
a fitted model object of class |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
A named numeric vector of estimated regression coefficients. The names correspond to the columns of the model matrix.
vcov.geer, confint.geer,
summary.geer.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) coef(fit)data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) coef(fit)
Computes Wald-type confidence intervals for one or more regression
parameters from a fitted geer object.
## S3 method for class 'geer' confint(object, parm, level = 0.95, cov_type = "bias-corrected", ...)## S3 method for class 'geer' confint(object, parm, level = 0.95, cov_type = "bias-corrected", ...)
object |
a fitted model object of class |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
a single number strictly between 0 and 1 specifying the
confidence level. Defaults to |
cov_type |
character string specifying the covariance matrix estimator
used for the standard errors: one of the estimators described in
|
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
The intervals are
, with standard
errors from vcov(object, cov_type = cov_type).
A matrix with columns giving lower and upper confidence limits for each
parameter. The columns are labeled by the corresponding tail probabilities
in percent, for example "2.5%" and "97.5%" when
level = 0.95.
vcov.geer, coef.geer,
tidy.geer.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) confint(fit) confint(fit, parm = "treatmentactive", cov_type = "robust")data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) confint(fit) confint(fit, parm = "treatmentactive", cov_type = "robust")
Data from a randomized clinical trial on the efficacy of oestrogen patches in treating postnatal depression.
depressiondepression
A data frame with 366 rows and 5 columns:
integer subject identifier.
integer follow-up month identifier.
numeric Edinburgh Postnatal Depression Scale (EPDS) score. Higher scores indicate greater depression.
factor with levels placebo and oestrogen.
numeric EPDS score at baseline.
Sixty-one women with major depression were randomly assigned to either a placebo control group or an oestrogen patch group (Gregoire et al., 1996), yielding 366 observations (six monthly assessments per subject). Before treatment, depressive symptoms were assessed using the Edinburgh Postnatal Depression Scale (EPDS). EPDS scores were then collected monthly for six months.
https://stats.oarc.ucla.edu/spss/library/spss-librarypanel-data-analysis-using-gee/
Gregoire, A.J.P., Kumar, R., Everitt, B., Henderson, A.F. and Studd, J.W.W. (1996) Transdermal oestrogen for treatment of severe postnatal depression. The Lancet, 347, 930–933.
data("depression", package = "geer") str(depression)data("depression", package = "geer") str(depression)
Methods that allow emmeans functions, such as
emmeans::emmeans(), to be applied to fitted geer objects.
They are called by emmeans and not usually by the user. Inference is
asymptotic, with infinite degrees of freedom, and uses the bias-corrected
covariance matrix unless vcov.method requests another estimator.
recover_data.geer(object, data = NULL, ...) emm_basis.geer( object, trms, xlev, grid, vcov.method = "bias-corrected", cov_type = NULL, vcov. = NULL, misc = NULL, ... )recover_data.geer(object, data = NULL, ...) emm_basis.geer( object, trms, xlev, grid, vcov.method = "bias-corrected", cov_type = NULL, vcov. = NULL, misc = NULL, ... )
object |
a fitted model object of class |
data |
optional data frame from which emmeans recovers the
predictors. Defaults to |
... |
additional arguments passed through from emmeans. |
trms |
the terms component supplied by emmeans. |
xlev |
the factor levels supplied by emmeans. |
grid |
the reference grid supplied by emmeans. |
vcov.method |
character string specifying the covariance matrix
estimator, one of the estimators described in |
cov_type |
optional alias of |
vcov. |
optional covariance matrix or function supplied through the
emmeans argument |
misc |
optional list passed through by emmeans. Defaults to
|
recover_data.geer() returns the predictor data, and
emm_basis.geer() the components from which emmeans builds a
reference grid.
vcov.geer, geewa,
geewa_binary.
if (requireNamespace("emmeans", quietly = TRUE)) { data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) emmeans::emmeans(fit, ~ treatment) emmeans::emmeans(fit, ~ treatment, type = "response") emmeans::emmeans(fit, ~ treatment, vcov.method = "naive") }if (requireNamespace("emmeans", quietly = TRUE)) { data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) emmeans::emmeans(fit, ~ treatment) emmeans::emmeans(fit, ~ treatment, type = "response") emmeans::emmeans(fit, ~ treatment, vcov.method = "naive") }
Data from a randomized clinical trial on the efficacy of progabide in treating partial seizures.
epilepsyepilepsy
A data frame with 236 rows and 6 columns:
integer subject identifier.
integer identifier of the two-week interval.
integer count of epileptic seizures.
factor with levels placebo and progabide.
numeric logarithm of one-quarter of the number of seizures in the baseline 8-week interval.
numeric logarithm of age in years.
Fifty-nine subjects with partial seizures were enrolled in a randomized clinical trial, yielding 236 observations (four visits per subject). Subjects were assigned to receive either progabide or placebo. Seizure counts were recorded during the 8 weeks before treatment (baseline). After treatment, seizure counts were assessed at four 2-week clinic visits. Carey and Wang (2011) use these data to compare working covariance structures.
Thall, P.F. and Vail, S.C. (1990) Some covariance models for longitudinal count data with overdispersion. Biometrics, 46, 657–671.
Carey, V.J. and Wang, Y.G. (2011) Working covariance model selection for generalized estimating equations. Statistics in Medicine, 30, 3117–3124.
data("epilepsy", package = "geer") str(epilepsy)data("epilepsy", package = "geer") str(epilepsy)
Extracts the fitted mean values on the response scale from a fitted
geer object. fitted.values is an alias for fitted.
## S3 method for class 'geer' fitted(object, ...)## S3 method for class 'geer' fitted(object, ...)
object |
a fitted model object of class |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
A numeric vector of fitted means, one per observation used in the fit, in the order given under Observation order.
The values follow the internal order of the fitted model: the complete
cases, sorted by cluster and, within cluster, by repeated. Unless the
data were already in this order and had no missing values, assigning the
values to the data, as in data$r <- residuals(fit), misaligns the
rows without warning. fit$id and fit$repeated are stored in
the same order and can be used to align them.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(fitted(fit))data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(fitted(fit))
Checks whether each working correlation of a fitted binary GEE model lies within the Fréchet bounds implied by the fitted marginal probabilities.
frechet_bounds_cor(object)frechet_bounds_cor(object)
object |
a fitted model object of class |
For observations at times and of cluster , with
fitted probabilities and , the
Fréchet bounds on their correlation are
The working correlation of a time pair is common to all clusters, whereas the bounds vary with the fitted probabilities. The bounds are undefined for fitted probabilities of 0 or 1, which usually indicate separation, and such fits give an error. Grouped binomial responses are not allowed. Clusters of size one are skipped, and time pairs observed in no cluster are omitted.
A data frame with one row per time pair and columns:
alpha_name |
the label |
alpha_value |
the working correlation. |
lower_max |
the largest lower bound over the clusters. |
upper_min |
the smallest upper bound over the clusters. |
n_clusters |
the number of clusters observed at both times. |
n_violated |
the number of clusters whose bounds do not contain
|
data("cholecystectomy", package = "geer") fit <- geewa( formula = pain ~ treatment + gender + age + I(time > 4), family = binomial(link = "logit"), data = cholecystectomy, id = id, repeated = time, corstr = "unstructured" ) frechet_bounds_cor(fit)data("cholecystectomy", package = "geer") fit <- geewa( formula = pain ~ treatment + gender + age + I(time > 4), family = binomial(link = "logit"), data = cholecystectomy, id = id, repeated = time, corstr = "unstructured" ) frechet_bounds_cor(fit)
Computes model selection criteria for one or more fitted geer objects,
for comparing marginal mean models and for selecting the working association
structure.
geecriteria(object, ..., criteria = "all", cov_type = "robust", digits = 2)geecriteria(object, ..., criteria = "all", cov_type = "robust", digits = 2)
object |
a fitted model object of class |
... |
additional fitted model objects of class |
criteria |
character vector of criterion names (see Details), matched
ignoring case, or |
cov_type |
character string specifying the covariance matrix estimator
used in the covariance-based penalty terms: one of the estimators described
in |
digits |
nonnegative integer giving the number of decimal places used
to round the criteria. Defaults to |
The available criteria are:
QIC, QICu
quasi-likelihood information criteria of Pan (2001).
QICHHQIC as modified by Hardin and Hilbe (2003, 2013).
QICCcorrected QIC of Hardin and Hilbe (2013).
CICcorrelation information criterion of Hin and Wang (2009).
RJCRotnitzky-Jewell criterion of Hin, Carey and Wang (2007), based on Rotnitzky and Jewell (1990).
EQICextended quasi-likelihood information criterion of Wang and Hin (2010).
GESSCgeneralized error sum of squares criterion of Shults and Chaganty (1998) and Shults et al. (2009).
GPC, AGPC, SGPC
Gaussian pseudolikelihood criterion and its Akaike-type and Schwarz-type penalized versions (Carey and Wang, 2011; Zhu and Zhu, 2013; Fu, Hao and Wang, 2018).
GHYCcriterion of Gosho, Hamada and Yoshimura (2011), denoted DEW by Gosho (2014).
PACcriterion of Pardo and Alonso (2019).
PT, WR, RMR
Pillai trace, Wilks ratio, and Roy maximum root type criteria of Jang (2011), also described by Pardo and Alonso (2019, Sections 3.6 to 3.8).
Smaller values are preferred for every criterion except GPC, for
which larger values are preferred. QIC and QICu are intended
mainly for comparing marginal mean models, and CIC, RJC,
GHYC, and PAC for selecting the working association
structure. The column
Parameters, the number of regression parameters, is always reported.
cov_type affects QIC, QICHH, QICC, CIC,
RJC, EQIC, PT, WR, and RMR; with
cov_type = "jackknife" each model is refitted once per cluster. A
criterion that cannot be evaluated for a fit is NA. A warning is
issued when the models differ in the number of observations, the family, or
the response values, because the criteria are then not comparable.
Let be the number of clusters, the number of
observations, the number of regression parameters, the
number of association parameters estimated from the data ( for
independence and for corstr = "fixed" or orstr = "fixed"),
the covariance estimate selected by cov_type and
the model-based information matrix under working
independence. Then:
, where is
the quasi-likelihood at , the ordinary GEE estimate
under working independence, refitted from the stored data.
, and NA when .
GESSC is the error sum of squares weighted by the inverse
working covariance matrices, divided by . Without
this divisor it is the criterion of Pardo and Alonso (2019),
and the two can rank structures differently.
With ,
and
, on the scale used by
glmtoolbox (Vanegas, Rondon and Paula, 2023).
With the eigenvalues of ,
,
, and
. They are
NA if an eigenvalue is not positive.
With and ,
and
. Both require a
balanced design, in which every cluster observes each repeated position
once, and are NA otherwise or when is singular.
EQIC uses the extended quasi-likelihood with the
Nelder-Pregibon adjustment . Its dispersion is 1 for
binomial models, the fixed value when phi_fixed = TRUE, and
otherwise the adjusted deviance divided by .
The quasi-likelihood in QIC, QICu, QICHH, and
QICC diverges when a fitted mean reaches the boundary of its support,
for example a fitted probability of 0 or 1. Fitted means are therefore kept
sqrt(.Machine$double.eps) away from the boundary. This does not
affect the comparison of association structures for the same mean model,
but these criteria should not be used to compare mean models when only some
of them reach the boundary; use CIC instead.
A data frame with one row per model, containing the requested criteria and
Parameters. When more than one model is supplied, the row names are
the deparsed model expressions, or "Model 1", "Model 2", and
so on for models supplied as objects rather than expressions, for example
through do.call.
Carey, V.J. and Wang, Y.G. (2011) Working covariance model selection for generalized estimating equations. Statistics in Medicine, 30, 3117–3124.
Fu, L., Hao, Y. and Wang, Y.G. (2018) Working correlation structure selection in generalized estimating equations. Computational Statistics, 33, 983–996.
Gosho, M. (2014) Criteria to select a working correlation structure for the generalized estimating equations method in SAS. Journal of Statistical Software, Code Snippets, 57, 1–10.
Gosho, M., Hamada, C. and Yoshimura, I. (2011) Criterion for the selection of a working correlation structure in the generalized estimating equation approach for longitudinal balanced data. Communications in Statistics – Theory and Methods, 40, 3839–3856.
Hardin, J.W. and Hilbe, J.M. (2003) Generalized Estimating Equations. Chapman and Hall/CRC, Boca Raton.
Hardin, J.W. and Hilbe, J.M. (2013) Generalized Estimating Equations, 2nd Edition. Chapman and Hall/CRC, Boca Raton.
Hin, L.Y., Carey, V.J. and Wang, Y.G. (2007) Criteria for working-correlation-structure selection in GEE: assessment via simulation. The American Statistician, 61, 360–364.
Hin, L.Y. and Wang, Y.G. (2009) Working-correlation-structure identification in generalized estimating equations. Statistics in Medicine, 28, 642–658.
Jang, M.J. (2011) Working correlation selection in generalized estimating equations. PhD dissertation, University of Iowa.
Pan, W. (2001) Akaike's information criterion in generalized estimating equations. Biometrics, 57, 120–125.
Pardo, M.C. and Alonso, R. (2019) Working correlation structure selection in GEE analysis. Statistical Papers, 60, 1447–1467.
Rotnitzky, A. and Jewell, N.P. (1990) Hypothesis testing of regression parameters in semiparametric generalized linear models for cluster correlated data. Biometrika, 77, 485–497.
Shults, J. and Chaganty, N.R. (1998) Analysis of serially correlated data using quasi-least squares. Biometrics, 54, 1622–1630.
Shults, J., Sun, W., Tu, X., Kim, H., Amsterdam, J., Hilbe, J.M. and Ten-Have, T. (2009) A comparison of several approaches for choosing between working correlation structures in generalized estimating equation analysis of longitudinal binary data. Statistics in Medicine, 28, 2338–2355.
Vanegas, L.H., Rondon, L.M. and Paula, G.A. (2023) Generalized Estimating Equations using the new R package glmtoolbox. The R Journal, 15, 105–133.
Wang, Y.G. and Hin, L.Y. (2010) Modeling strategies in longitudinal data analysis: covariate, variance function and correlation structure selection. Computational Statistics & Data Analysis, 54, 3359–3370.
Zhu, X. and Zhu, Z. (2013) Comparison of criteria to select working correlation matrix in generalized estimating equations. Chinese Journal of Applied Probability and Statistics, 29, 515–530.
vcov.geer, step_criterion,
step_p, glance.geer, anova.geer, geewa,
geewa_binary.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) geecriteria(fit) ## Compare working correlation structures fit_ind <- update(fit, corstr = "independence") fit_ar1 <- update(fit, corstr = "ar1") geecriteria(fit_ind, fit, fit_ar1) ## Selected criteria, in the order requested geecriteria(fit_ind, fit, fit_ar1, criteria = c("cic", "QIC")) ## Compare estimation methods fit_br <- update(fit, method = "brgee-robust") geecriteria(fit, fit_br)data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) geecriteria(fit) ## Compare working correlation structures fit_ind <- update(fit, corstr = "independence") fit_ar1 <- update(fit, corstr = "ar1") geecriteria(fit_ind, fit, fit_ar1) ## Selected criteria, in the order requested geecriteria(fit_ind, fit, fit_ar1, criteria = c("cic", "QIC")) ## Compare estimation methods fit_br <- update(fit, method = "brgee-robust") geecriteria(fit, fit_br)
Sets the control parameters of the fitting algorithm of geewa
and geewa_binary.
geer_control( tolerance = 1e-06, maxiter = 500, or_adding = 0.5, step_maxiter = 10, step_multiplier = 1, jeffreys_power = 0.5 )geer_control( tolerance = 1e-06, maxiter = 500, or_adding = 0.5, step_maxiter = 10, step_multiplier = 1, jeffreys_power = 0.5 )
tolerance |
strictly positive number giving the convergence tolerance.
Defaults to |
maxiter |
positive integer giving the maximum number of iterations.
Defaults to |
or_adding |
strictly positive number added to each cell of the
marginalized |
step_maxiter |
positive integer giving the maximum number of
step-halvings in an iteration. Defaults to |
step_multiplier |
strictly positive number scaling the proposed step
before step-halving. Values below 1 damp the step, which can help when the
algorithm diverges from poor starting values. Defaults to |
jeffreys_power |
strictly positive number giving the power of the
Jeffreys-type penalty of the methods |
A list with components tolerance, maxiter,
or_adding, step_maxiter, step_multiplier, and
jeffreys_power.
Touloumis, A. (2026b) Jeffreys-type penalized GEE for correlated binary data with an odds-ratio parameterization. arXiv preprint. doi:10.48550/arXiv.2606.16058
## Default control parameters geer_control() ## Tighter tolerance and fewer iterations geer_control(tolerance = 1e-08, maxiter = 200) ## Larger continuity correction for the odds-ratio estimates geer_control(or_adding = 1) ## Weaker Jeffreys-type penalty geer_control(jeffreys_power = 0.1) ## Damped steps, useful when the algorithm diverges geer_control(step_multiplier = 0.5)## Default control parameters geer_control() ## Tighter tolerance and fewer iterations geer_control(tolerance = 1e-08, maxiter = 200) ## Larger continuity correction for the odds-ratio estimates geer_control(or_adding = 1) ## Weaker Jeffreys-type penalty geer_control(jeffreys_power = 0.1) ## Damped steps, useful when the algorithm diverges geer_control(step_multiplier = 0.5)
Fits a marginal model for clustered or repeated responses by generalized estimating equations (GEE), using ordinary, bias-reduced, bias-corrected, or Jeffreys-type penalized GEE.
geewa( formula, family = stats::gaussian(link = "identity"), data = parent.frame(), id, repeated, control = geer_control(...), corstr = "independence", Mv = 1, method = "gee", weights, beta_start = NULL, offset, control_glm = list(...), use_p = TRUE, alpha_vector = NULL, phi_fixed = FALSE, phi_value = 1, subset, na.action, ... )geewa( formula, family = stats::gaussian(link = "identity"), data = parent.frame(), id, repeated, control = geer_control(...), corstr = "independence", Mv = 1, method = "gee", weights, beta_start = NULL, offset, control_glm = list(...), use_p = TRUE, alpha_vector = NULL, phi_fixed = FALSE, phi_value = 1, subset, na.action, ... )
formula |
formula of the form |
family |
family object, family function, or character string naming a
family, specifying the marginal variance and link functions. Supported
families are |
data |
optional data frame in long format, with one row per
observation, containing the variables in |
id |
variable identifying the clusters. |
repeated |
optional variable identifying the order of the observations
within each cluster. Its values must be unique within each cluster. They
are replaced by their rank among the sorted distinct values, or by the
level number for a factor, so only their order matters and not their
spacing. A character variable is sorted alphabetically, so |
control |
list of control parameters as returned by
|
corstr |
character string specifying the working correlation structure:
|
Mv |
positive integer giving the order of the |
method |
character string specifying the estimation method: ordinary GEE
( |
weights |
optional numeric vector of strictly positive, finite observation weights. Defaults to weights of 1. |
beta_start |
optional numeric vector of starting values for the
regression parameters. Defaults to |
offset |
optional a priori known component of the linear predictor:
a single number or a numeric vector with one value per observation. It is
added to any |
control_glm |
optional list of control parameters passed to
|
use_p |
logical indicating whether the number of regression parameters
is subtracted from the denominators of the estimators of the dispersion
and working correlation parameters. Defaults to |
alpha_vector |
numeric vector of working correlation parameters for
|
phi_fixed |
logical indicating whether the dispersion parameter is
fixed at |
phi_value |
strictly positive number giving the fixed value of the
dispersion parameter when |
subset |
optional vector specifying a subset of observations to be used
in the fit, evaluated in |
na.action |
function specifying the handling of missing values, as in
|
... |
arguments used to build |
The estimation methods are:
"gee"the estimating equations of Liang and Zeger (1986).
"brgee-*"bias-reduced GEE, which add an adjustment term to the estimating equations based on the naive, robust, or empirical covariance matrix (Touloumis, 2026a).
"bcgee-*"bias-corrected GEE, which apply a one-step correction to the converged GEE estimate (Touloumis, 2026a).
"pgee-jeffreys"GEE penalized by a Jeffreys-type penalty (Touloumis, 2026b).
"opgee-jeffreys", "hpgee-jeffreys"
one penalized, or one ordinary, scoring step from the penalized estimate under working independence.
Observations are sorted by id and repeated, and both are
recoded to consecutive integers. The quasi families are mapped to the
corresponding standard families: quasibinomial to binomial,
quasipoisson to poisson, and quasi with variance
"constant", "mu(1-mu)", "mu", "mu^2", or
"mu^3" to gaussian, binomial, poisson,
Gamma, or inverse.gaussian. The dispersion parameter is
estimated for every family unless phi_fixed = TRUE.
For corstr = "ar1", the correlation parameter is estimated from the
products of Pearson residuals at consecutive repeated values, pooled
over clusters, so it can differ from the estimates of other packages.
An object of class "geer", a list with components:
coefficients |
a named vector of estimated regression coefficients. |
residuals |
the working residuals. |
fitted.values |
the fitted mean values, obtained by transforming the linear predictors by the inverse of the link function. |
rank |
the numeric rank of the fitted model. |
family |
the |
linear.predictors |
the linear fit on the link scale. |
iter |
the number of iterations used. |
prior.weights |
the weights initially supplied, a vector of 1s if none were. |
df.residual |
the residual degrees of freedom. |
y |
the response vector. |
x |
the model matrix. |
qr |
the QR decomposition of the model matrix, used for estimability checking. |
id |
the recoded cluster identifier vector. |
repeated |
the recoded within-cluster ordering vector. |
cluster_labels |
the cluster identifiers supplied, in the order of
their recoded values in |
repeated_labels |
the values of |
converged |
logical indicating whether the algorithm converged. |
call |
the matched call. |
formula |
the formula supplied. |
terms |
the |
data |
the data argument. |
offset |
the offset vector used. |
control |
the |
method |
character string identifying the estimation method used. |
fit_function |
character string identifying the fitting function used,
either |
use_p |
logical indicating whether the degrees-of-freedom correction
was used; |
phi_fixed |
logical indicating whether the dispersion parameter was
fixed; |
contrasts |
the contrasts used. |
xlevels |
a record of the levels of the factors used in fitting. |
na.action |
the |
naive_covariance |
the model-based (naive) covariance matrix. |
robust_covariance |
the sandwich (robust) covariance matrix. |
bias_corrected_covariance |
the bias-corrected covariance matrix. |
association_structure |
the name of the working association structure. |
alpha |
the estimated or fixed working association parameters, 0 under independence. |
phi |
the estimated or fixed dispersion parameter, 1 for
|
obs_no |
the number of observations used in fitting. |
clusters_no |
the number of clusters. |
min_cluster_size |
the minimum cluster size. |
max_cluster_size |
the maximum cluster size. |
Other components are for internal use.
For the two-stage methods ("bcgee-*", "opgee-jeffreys", and
"hpgee-jeffreys"), alpha and phi are estimated once at
the first-stage estimate and held fixed in the correction step, and
converged is TRUE unless the correction step fails, in which
case the first-stage estimates are returned with a warning.
If converged is FALSE, the results are those of the last
accepted iteration and should not be interpreted; print() and
summary() then show a warning. converged = TRUE only means
that the stopping criterion was met: with separated binary data or all-zero
counts the estimates can be very large, which is signaled by a warning that
fitted probabilities are within 1e-12 of 0 or 1 or that fitted rates are 0.
In the bias-reduced and penalized methods the adjustment term is multiplied
by the dispersion parameter, whose estimate tends to 0 under complete
separation, so with the default estimated dispersion no method protects
against infinite estimates. For binary responses with separation or rare
events, use phi_fixed = TRUE or geewa_binary. Then
"brgee-naive" and the Jeffreys-penalized methods
("pgee-jeffreys", "opgee-jeffreys", and
"hpgee-jeffreys") keep the estimates finite under separation.
"brgee-robust" and "brgee-empirical" do not, and the
bias-corrected methods fail because they start from the ordinary GEE fit.
Liang, K.Y. and Zeger, S.L. (1986) Longitudinal data analysis using generalized linear models. Biometrika, 73, 13–22.
Touloumis, A. (2026a) Bias-reduced GEE via adjusted estimating equations, with odds-ratio extensions. arXiv preprint. doi:10.48550/arXiv.2606.16043
Touloumis, A. (2026b) Jeffreys-type penalized GEE for correlated binary data with an odds-ratio parameterization. arXiv preprint. doi:10.48550/arXiv.2606.16058
geewa_binary, geer_control,
summary.geer, vcov.geer,
anova.geer, step_p, geecriteria,
runs_test.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable", method = "gee" ) summary(fit) ## Bias-reduced and bias-corrected GEE fit_br <- update(fit, method = "brgee-robust") summary(fit_br) fit_bc <- update(fit, method = "bcgee-robust") summary(fit_bc, cov_type = "robust") ## Jeffreys-type penalized GEE with a weaker penalty fit_pgee <- update(fit, method = "pgee-jeffreys", control = geer_control(jeffreys_power = 0.1)) summary(fit_pgee)data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable", method = "gee" ) summary(fit) ## Bias-reduced and bias-corrected GEE fit_br <- update(fit, method = "brgee-robust") summary(fit_br) fit_bc <- update(fit, method = "bcgee-robust") summary(fit_bc, cov_type = "robust") ## Jeffreys-type penalized GEE with a weaker penalty fit_pgee <- update(fit, method = "pgee-jeffreys", control = geer_control(jeffreys_power = 0.1)) summary(fit_pgee)
Fits a marginal model for clustered or repeated binary responses by generalized estimating equations (GEE), with the association between responses modeled by marginalized pairwise odds ratios, using ordinary, bias-reduced, bias-corrected, or Jeffreys-type penalized GEE.
geewa_binary( formula, link = "logit", data = parent.frame(), id, repeated, control = geer_control(...), orstr = "independence", method = "gee", weights, beta_start = NULL, offset, control_glm = list(...), alpha_vector = NULL, subset, na.action, ... )geewa_binary( formula, link = "logit", data = parent.frame(), id, repeated, control = geer_control(...), orstr = "independence", method = "gee", weights, beta_start = NULL, offset, control_glm = list(...), alpha_vector = NULL, subset, na.action, ... )
formula |
formula of the form |
link |
character string specifying the link function: |
data |
optional data frame in long format, with one row per
observation, containing the variables in |
id |
variable identifying the clusters. |
repeated |
optional variable identifying the order of the observations
within each cluster. Its values must be unique within each cluster. They
are replaced by their rank among the sorted distinct values, or by the
level number for a factor, so only their order matters and not their
spacing. A character variable is sorted alphabetically, so |
control |
list of control parameters as returned by
|
orstr |
character string specifying the working odds-ratio structure:
|
method |
character string specifying the estimation method: ordinary GEE
( |
weights |
optional numeric vector of strictly positive, finite observation weights. Defaults to weights of 1. |
beta_start |
optional numeric vector of starting values for the
regression parameters. Defaults to |
offset |
optional a priori known component of the linear predictor:
a single number or a numeric vector with one value per observation. It is
added to any |
control_glm |
optional list of control parameters passed to
|
alpha_vector |
numeric vector of strictly positive, finite odds ratios
for |
subset |
optional vector specifying a subset of observations to be used
in the fit, evaluated in |
na.action |
function specifying the handling of missing values, as in
|
... |
arguments used to build |
The estimation methods are described in geewa. The marginal
mean model uses the binomial family with the given link, the working
odds ratios are estimated from marginalized tables (see
or_adding in geer_control), and the dispersion
parameter is fixed at 1. Observations are sorted by id and
repeated, and both are recoded to consecutive integers.
An object of class "geer", a list with components:
coefficients |
a named vector of estimated regression coefficients. |
residuals |
the working residuals. |
fitted.values |
the fitted mean values, obtained by transforming the linear predictors by the inverse of the link function. |
rank |
the numeric rank of the fitted model. |
family |
the |
linear.predictors |
the linear fit on the link scale. |
iter |
the number of iterations used. |
prior.weights |
the weights initially supplied, a vector of 1s if none were. |
df.residual |
the residual degrees of freedom. |
y |
the response vector. |
x |
the model matrix. |
qr |
the QR decomposition of the model matrix, used for estimability checking. |
id |
the recoded cluster identifier vector. |
repeated |
the recoded within-cluster ordering vector. |
cluster_labels |
the cluster identifiers supplied, in the order of
their recoded values in |
repeated_labels |
the values of |
converged |
logical indicating whether the algorithm converged. |
call |
the matched call. |
formula |
the formula supplied. |
terms |
the |
data |
the data argument. |
offset |
the offset vector used. |
control |
the |
method |
character string identifying the estimation method used. |
fit_function |
character string identifying the fitting function used,
either |
use_p |
logical indicating whether the degrees-of-freedom correction
was used; |
phi_fixed |
logical indicating whether the dispersion parameter was
fixed; |
contrasts |
the contrasts used. |
xlevels |
a record of the levels of the factors used in fitting. |
na.action |
the |
naive_covariance |
the model-based (naive) covariance matrix. |
robust_covariance |
the sandwich (robust) covariance matrix. |
bias_corrected_covariance |
the bias-corrected covariance matrix. |
association_structure |
the name of the working association structure. |
alpha |
the estimated or fixed working association parameters, 0 under independence. |
phi |
the estimated or fixed dispersion parameter, 1 for
|
obs_no |
the number of observations used in fitting. |
clusters_no |
the number of clusters. |
min_cluster_size |
the minimum cluster size. |
max_cluster_size |
the maximum cluster size. |
Other components are for internal use.
Here phi is always 1 and alpha contains the working odds
ratios, which are 1 under independence and are computed once from the data,
so they are the same in both stages of the two-stage methods.
For the two-stage methods ("bcgee-*", "opgee-jeffreys", and
"hpgee-jeffreys"), converged is TRUE unless the
correction step fails, in which case the first-stage estimates are returned
with a warning. If converged is FALSE, the results are those
of the last accepted iteration and should not be interpreted.
converged = TRUE only means that the stopping criterion was met: with
separated data the estimates can be very large, which is signaled by a
warning that fitted probabilities are within 1e-12 of 0 or 1. Because the
dispersion is fixed, "brgee-naive" and the Jeffreys-penalized methods
("pgee-jeffreys", "opgee-jeffreys", and
"hpgee-jeffreys") keep the estimates finite under separation.
"brgee-robust" and "brgee-empirical" do not, and the
bias-corrected methods fail because they start from the ordinary GEE fit.
Touloumis, A. (2026a) Bias-reduced GEE via adjusted estimating equations, with odds-ratio extensions. arXiv preprint. doi:10.48550/arXiv.2606.16043
Touloumis, A. (2026b) Jeffreys-type penalized GEE for correlated binary data with an odds-ratio parameterization. arXiv preprint. doi:10.48550/arXiv.2606.16058
geewa, geer_control,
summary.geer, vcov.geer,
anova.geer, step_p, geecriteria,
runs_test.
data("cholecystectomy", package = "geer") fit <- geewa_binary( formula = pain ~ treatment + gender + age, link = "logit", data = cholecystectomy, id = id, repeated = time, orstr = "independence", method = "gee" ) summary(fit) ## Bias-reduced and bias-corrected GEE fit_br <- update(fit, method = "brgee-robust") summary(fit_br) fit_bc <- update(fit, method = "bcgee-robust") summary(fit_bc, cov_type = "robust") ## Jeffreys-type penalized GEE with an exchangeable odds-ratio structure fit_pgee <- update(fit, orstr = "exchangeable", method = "pgee-jeffreys") summary(fit_pgee) ## Probit link fit_probit <- update(fit, link = "probit") summary(fit_probit)data("cholecystectomy", package = "geer") fit <- geewa_binary( formula = pain ~ treatment + gender + age, link = "logit", data = cholecystectomy, id = id, repeated = time, orstr = "independence", method = "gee" ) summary(fit) ## Bias-reduced and bias-corrected GEE fit_br <- update(fit, method = "brgee-robust") summary(fit_br) fit_bc <- update(fit, method = "bcgee-robust") summary(fit_bc, cov_type = "robust") ## Jeffreys-type penalized GEE with an exchangeable odds-ratio structure fit_pgee <- update(fit, orstr = "exchangeable", method = "pgee-jeffreys") summary(fit_pgee) ## Probit link fit_probit <- update(fit, link = "probit") summary(fit_probit)
Summarizes a fitted geer object in a one-row data frame, following
the conventions of broom (Robinson, Hayes and Couch, 2024).
## S3 method for class 'geer' glance(x, ...)## S3 method for class 'geer' glance(x, ...)
x |
a fitted model object of class |
... |
additional arguments passed to or from other methods. Currently unused. |
QIC and CIC use the robust covariance matrix, as in
geecriteria(x, cov_type = "robust"), and are NA if they
cannot be computed. See geecriteria for further criteria.
A one-row data frame, a tibble if tibble is installed, with columns:
family, link
|
the family and link function. |
method |
the estimation method. |
wastr |
the working association structure, |
nobs, nclusters
|
the numbers of observations and clusters. |
min.cluster.size, max.cluster.size
|
the smallest and largest cluster sizes. |
npar |
the number of regression parameters. |
df.residual |
the number of observations minus |
phi |
the dispersion parameter, 1 for |
QIC, QICu
|
the quasi-likelihood information criteria of Pan (2001). |
CIC |
the correlation information criterion of Hin and Wang (2009). |
converged |
logical indicating whether the algorithm converged. |
niter |
the number of iterations. |
Hin, L.Y. and Wang, Y.G. (2009) Working-correlation-structure identification in generalized estimating equations. Statistics in Medicine, 28, 642–658.
Pan, W. (2001) Akaike's information criterion in generalized estimating equations. Biometrics, 57, 120–125.
Robinson, D., Hayes, A. and Couch, S. (2024) broom: Convert Statistical Objects into Tidy Tibbles. R package. https://broom.tidymodels.org/
tidy.geer, geecriteria,
geewa, geewa_binary.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) glance(fit) ## Compare working correlation structures fit_ar1 <- update(fit, corstr = "ar1") rbind(glance(fit), glance(fit_ar1))data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) glance(fit) ## Compare working correlation structures fit_ar1 <- update(fit, corstr = "ar1") rbind(glance(fit), glance(fit_ar1))
Computes leverages, the change in the estimated regression coefficients
when a cluster or an observation is deleted, and Cook's distances for a
fitted geer object.
## S3 method for class 'geer' hatvalues(model, level = c("clusters", "observations"), ...) ## S3 method for class 'geer' dfbeta( model, level = c("clusters", "observations"), method = c("one-step", "exact"), ... ) ## S3 method for class 'geer' dfbetas( model, level = c("clusters", "observations"), method = c("one-step", "exact"), cov_type = "naive", ... ) ## S3 method for class 'geer' cooks.distance( model, level = c("clusters", "observations"), method = c("one-step", "exact"), cov_type = "naive", parm, ... )## S3 method for class 'geer' hatvalues(model, level = c("clusters", "observations"), ...) ## S3 method for class 'geer' dfbeta( model, level = c("clusters", "observations"), method = c("one-step", "exact"), ... ) ## S3 method for class 'geer' dfbetas( model, level = c("clusters", "observations"), method = c("one-step", "exact"), cov_type = "naive", ... ) ## S3 method for class 'geer' cooks.distance( model, level = c("clusters", "observations"), method = c("one-step", "exact"), cov_type = "naive", parm, ... )
model |
a fitted model object of class |
level |
character string specifying whether the diagnostics refer to
clusters ( |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
method |
character string specifying how the deletion estimates are
obtained: the one-step approximation of Preisser and Qaqish (1996)
( |
cov_type |
character string specifying the covariance matrix estimator
used to standardize the deletion estimates: one of the estimators
described in |
parm |
a specification of which coefficients enter Cook's distance, either a vector of numbers or a vector of names. If missing, all coefficients are used. |
Let be the derivative of the mean vector of cluster with
respect to , its working covariance matrix, including
the dispersion, and
the naive covariance matrix. The leverage
matrix of cluster is
hatvalues() returns the diagonal elements of for
level = "observations" and their sum, the trace of , for
level = "clusters". The leverages sum to the number of coefficients.
dfbeta() returns ,
where is the estimate without cluster or
observation . With method = "one-step", it is a single
Fisher scoring step from with the association and
dispersion parameters held at their full-data values (Preisser and Qaqish,
1996). For a cluster this is
as in equation (4.66) of Hardin and Hilbe (2013). For observation
of cluster , the step uses the residual, the derivative and the
variance of conditional on the remaining observations of
the cluster under the working covariance matrix. This differs from equation
(4.67) of Hardin and Hilbe (2013), which ignores the correlation with the
rest of the cluster and agrees with it only under working independence.
Both one-step approximations are exact for a Gaussian response with the
identity link.
With method = "exact", every cluster is deleted in turn and the model
refitted with the association parameters held at their full-data values,
as for cov_type = "jackknife" in vcov.geer. The
refits are computed once and cached on the fit. It is available only for
level = "clusters". The one-step approximation is derived from the
ordinary generalized estimating equations, so it is available only for
fits with method = "gee"; for the other estimation methods, use
method = "exact".
When deleting a cluster or an observation leaves coefficients that cannot be
estimated, for example the only cluster at a level of a factor, the
leverage matrix has an eigenvalue of 1 and the deletion estimate
is undefined. Its values are then NA, with a warning naming the
clusters or observations, and no refit is attempted for them with
method = "exact".
dfbetas() divides each column of dfbeta() by the standard
error of the coefficient from vcov(model, cov_type = cov_type).
cooks.distance() returns
where the coefficients are restricted to those in parm, is
their number and their covariance matrix from
vcov(model, cov_type = cov_type). With the default
cov_type = "naive" and all coefficients, this is equation (4.68) of
Hardin and Hilbe (2013) for clusters, and the corresponding measure of
Preisser and Qaqish (1996) for observations. glmtoolbox uses the
robust covariance matrix by default.
For hatvalues() and cooks.distance(), a numeric vector with
one value per cluster, named by the cluster identifier, or one value per
observation, in the order and with the names given under Observation
order. For
dfbeta() and dfbetas(), a matrix with one row per cluster
or observation, in the same order, and one column per coefficient.
For level = "observations", the values follow the internal order of
the fitted model: the complete cases, sorted by cluster and, within
cluster, by repeated. They are named "id(repeated)" by the
cluster identifier and the value of repeated, or the position within
the cluster if repeated was not supplied.
Hardin, J.W. and Hilbe, J.M. (2013) Generalized Estimating Equations, 2nd Edition. Chapman and Hall/CRC, Boca Raton.
Preisser, J.S. and Qaqish, B.F. (1996) Deletion diagnostics for generalised estimating equations. Biometrika, 83, 551–562.
Vanegas, L.H., Rondon, L.M. and Paula, G.A. (2023) Generalized Estimating Equations using the new R package glmtoolbox. The R Journal, 15, 105–133.
local_influence, residuals.geer,
vcov.geer, geewa, geewa_binary.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, data = epilepsy, id = id, repeated = visit, family = poisson(link = "log"), corstr = "exchangeable" ) head(hatvalues(fit)) head(dfbeta(fit)) head(dfbetas(fit, cov_type = "robust")) head(cooks.distance(fit)) head(cooks.distance(fit, level = "observations")) head(cooks.distance(fit, parm = "treatmentprogabide"))data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, data = epilepsy, id = id, repeated = visit, family = poisson(link = "log"), corstr = "exchangeable" ) head(hatvalues(fit)) head(dfbeta(fit)) head(dfbetas(fit, cov_type = "robust")) head(cooks.distance(fit)) head(cooks.distance(fit, level = "observations")) head(cooks.distance(fit, parm = "treatmentprogabide"))
Data from a randomized clinical trial on the efficacy of antibiotic treatments for leprosy in the Philippines.
leprosyleprosy
A data frame with 60 rows and 4 columns:
integer subject identifier.
factor period identifier with levels pre and
post.
integer count of leprosy bacilli at six body sites.
factor with levels A, B, and C,
where C denotes placebo.
Thirty subjects in the Philippines were enrolled in a randomized clinical trial, yielding 60 observations (two periods per subject). Subjects were assigned to receive treatment A, B, or C (placebo). Before treatment, the number of leprosy bacilli at six body sites was recorded. After treatment, bacilli counts were recorded again. The trial aimed to assess whether treatments A and B reduced bacilli abundance compared with placebo.
Snedecor, G.W. and Cochran, W.G. (1967) Statistical Methods. Iowa State University Press, Ames.
data("leprosy", package = "geer") str(leprosy)data("leprosy", package = "geer") str(leprosy)
Computes local influence measures (Cook, 1986) of the clusters or the
observations on the estimated regression coefficients of a fitted
geer object.
local_influence( object, perturbation = c("cluster-weights", "observation-weights", "response"), type = c("total", "local"), parm )local_influence( object, perturbation = c("cluster-weights", "observation-weights", "response"), type = c("total", "local"), parm )
object |
a fitted model object of class |
perturbation |
character string specifying the perturbation scheme:
case weights on the clusters ( |
type |
character string specifying the measure: the total local
influence of each cluster or observation ( |
parm |
a specification of which coefficients are of interest, either a vector of numbers or a vector of names. If missing, all coefficients are used. |
Let be the generalized estimating
equations perturbed by , with
giving the unperturbed equations,
and
, both evaluated
at and . The curvature in the
direction , , is
With type = "total", the value for cluster or observation
is the total local influence , the curvature in the
direction of the -th unit vector (Lesaffre and Verbeke, 1998). With
type = "local", it is the absolute value of the -th element
of , the eigenvector of the symmetric part of
with the largest
absolute eigenvalue, computed by an eigendecomposition. Only the symmetric
part enters , and is in general not symmetric
for geewa fits. When parm
selects a subset of the coefficients, is replaced by
,
where is the block of the other coefficients
(Cook, 1986).
With perturbation = "cluster-weights", the contribution of cluster
to the estimating equations is multiplied by
. With "observation-weights", the
contribution of observation of cluster is multiplied by
, that is,
. With "response", the response
is replaced by
, where
is the working variance of . Here
is the derivative of the mean vector of cluster with
respect to and its working covariance matrix,
including the dispersion.
is the observed derivative of the estimating equations with the
association and dispersion parameters held at their estimates, including
the dependence of on the means, which for
geewa_binary fits also enters through the odds ratios. The
measures are derived from the ordinary generalized estimating equations,
so they are available only for fits with method = "gee".
glmtoolbox (Vanegas, Rondon and Paula, 2023) reports
without the factor 2 and the absolute value, and leaves the dispersion out
of , so that its total local influence for the weight
perturbations is times that of local_influence()
divided by 2, while the response perturbation does not depend on these
conventions. glmtoolbox also inverts through a Cholesky
factorization, which uses only its upper triangle, so its values differ
from those of local_influence() when is not symmetric, as
for a correlated working structure unless the response is Gaussian with
the identity link.
A numeric vector with one value per cluster, named by the cluster
identifier, for perturbation = "cluster-weights", and one value per
observation, in the order and with the names given under Observation order,
otherwise.
For perturbation = "observation-weights" and "response", the
values follow the internal order of the fitted model: the complete cases,
sorted by cluster and, within cluster, by repeated. They are named
"id(repeated)" by the cluster identifier and the value of
repeated, or the position within the cluster if repeated
was not supplied.
Cook, R.D. (1986) Assessment of local influence. Journal of the Royal Statistical Society, Series B, 48, 133–169.
Lesaffre, E. and Verbeke, G. (1998) Local influence in linear mixed models. Biometrics, 54, 570–582.
Vanegas, L.H., Rondon, L.M. and Paula, G.A. (2023) Generalized Estimating Equations using the new R package glmtoolbox. The R Journal, 15, 105–133.
cooks.distance.geer, hatvalues.geer,
geewa, geewa_binary.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, data = epilepsy, id = id, repeated = visit, family = poisson(link = "log"), corstr = "exchangeable" ) head(local_influence(fit)) head(local_influence(fit, type = "local")) head(local_influence(fit, perturbation = "response")) head(local_influence(fit, parm = "treatmentprogabide"))data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, data = epilepsy, id = id, repeated = visit, family = poisson(link = "log"), corstr = "exchangeable" ) head(local_influence(fit)) head(local_influence(fit, type = "local")) head(local_influence(fit, perturbation = "response")) head(local_influence(fit, parm = "treatmentprogabide"))
Methods that allow marginaleffects functions, such as
marginaleffects::predictions(), marginaleffects::comparisons(),
and marginaleffects::slopes(), to be applied to fitted geer
objects. They are called by marginaleffects and not usually by the
user. Inference uses the bias-corrected covariance matrix unless
vcov requests another estimator.
## S3 method for class 'geer' get_data(x, ...) ## S3 method for class 'geer' get_coef(model, ...) ## S3 method for class 'geer' set_coef(model, coefs, ...) ## S3 method for class 'geer' get_vcov(model, vcov = NULL, ...) ## S3 method for class 'geer' get_predict(model, newdata = NULL, type = NULL, ...)## S3 method for class 'geer' get_data(x, ...) ## S3 method for class 'geer' get_coef(model, ...) ## S3 method for class 'geer' set_coef(model, coefs, ...) ## S3 method for class 'geer' get_vcov(model, vcov = NULL, ...) ## S3 method for class 'geer' get_predict(model, newdata = NULL, type = NULL, ...)
x |
a fitted model object of class |
... |
additional arguments passed through by marginaleffects. |
model |
a fitted model object of class |
coefs |
a named numeric vector of regression coefficients. |
vcov |
covariance specification: |
newdata |
optional data frame of predictor values at which predictions
are computed. Defaults to |
type |
character string specifying the prediction scale,
|
These methods return objects in the formats required internally by
marginaleffects: a named coefficient vector, a modified geer
object, a named covariance matrix (or NULL when
vcov = FALSE), a model data frame, or a data frame with columns
rowid and estimate.
predict.geer, vcov.geer,
coef.geer.
if (requireNamespace("marginaleffects", quietly = TRUE)) { data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) marginaleffects::avg_predictions(fit) marginaleffects::avg_comparisons(fit, variables = "treatment") marginaleffects::avg_predictions(fit, vcov = "robust") }if (requireNamespace("marginaleffects", quietly = TRUE)) { data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) marginaleffects::avg_predictions(fit) marginaleffects::avg_comparisons(fit, variables = "treatment") marginaleffects::avg_predictions(fit, vcov = "robust") }
Tests the homogeneity of the covariance matrices across missingness patterns, a consequence of MCAR, by the procedure of Jamshidian and Jalal (2010) as implemented in MissMech (Jamshidian, Jalal and Jansen, 2014).
mcar_homoscedasticity_test( object, data = NULL, method = c("auto", "nonparametric", "hawkins"), imputation = c("distribution-free", "normal"), n_imputations = 1L, imputed_data = NULL, min_pattern_size = 7L, nrep = 10000L, n_min = 30L, alpha = 0.05, seed = 110L, maxit = 1000L, tol = 1e-08 )mcar_homoscedasticity_test( object, data = NULL, method = c("auto", "nonparametric", "hawkins"), imputation = c("distribution-free", "normal"), n_imputations = 1L, imputed_data = NULL, min_pattern_size = 7L, nrep = 10000L, n_min = 30L, alpha = 0.05, seed = 110L, maxit = 1000L, tol = 1e-08 )
object |
a fitted model object of class |
data |
optional data frame containing the data used to fit
|
method |
character string specifying the diagnostic: the modified
Hawkins test ( |
imputation |
character string specifying how the data are completed
before testing: by adding resampled complete-case residuals to the best
linear predictors of the missing values ( |
n_imputations |
positive integer giving the number of imputed data sets.
The primary results use the first one, as in MissMech, and the
results for all of them are returned in |
imputed_data |
optional completed version of the matrix or data frame
supplied in |
min_pattern_size |
integer, at least 2, giving the minimum number of
cases for a missingness pattern to be retained. Defaults to |
nrep |
positive integer giving the number of simulated samples for the
null distribution of the Neyman statistic in patterns with fewer than
|
n_min |
integer, at least 2, giving the pattern size from which the
chi-squared reference with four degrees of freedom is used for the Neyman
statistic. Defaults to |
alpha |
a single number strictly between 0 and 1 giving the significance
level of the rule used with |
seed |
|
maxit |
positive integer giving the maximum number of iterations of the
EM algorithm used for normal-theory imputation. Defaults to |
tol |
a single positive finite number giving the relative convergence
tolerance of the EM algorithm. Defaults to |
The procedure completes the incomplete data by imputation, groups the cases
by their original missingness pattern, and tests whether the completed data
have a common covariance matrix across patterns. Patterns with fewer than
min_pattern_size cases are omitted; at least two patterns, one of
them with missing values, must remain.
Two tests are available. The modified Hawkins test (Hawkins, 1981)
transforms the within-pattern Mahalanobis distances to variables that are
Uniform(0, 1) under multivariate normality and homogeneous covariances,
applies a fourth-order Neyman smooth test within each pattern, and combines
the pattern p-values by Fisher's method. For patterns with fewer than
n_min cases the null distribution of the Neyman statistic is
simulated and the p-value is , where is the
number of simulated statistics at least as large as the observed one. The
nonparametric test compares the distributions of the transformed distances
across patterns with the k-sample Anderson-Darling test of Scholz and
Stephens (1987), which is less sensitive to nonnormality. With
method = "auto" both tests are computed: if the Hawkins test does not
reject, there is no evidence against MCAR; if it rejects but the
nonparametric test does not, the rejection is attributed to nonnormality;
rejection by the nonparametric test is evidence against covariance
homogeneity and hence against MCAR.
Distribution-free imputation, in the spirit of Srivastava and Dolatabadi
(2009), requires at least 10, and at least , complete cases among the
retained rows, where is the number of variables; otherwise
normal-theory imputation is used with a warning. Because normal-theory
imputation can inflate the size of the nonparametric test for nonnormal data,
requesting it with method other than "hawkins" gives a warning.
imputed_data is intended for matrix or data frame input, since the
matrix reconstructed from a fitted model object is not returned.
The implementation follows MissMech (Jamshidian, Jalal and Jansen,
2014), which differs from Jamshidian and Jalal (2010) in that one imputation
method serves both tests, normal-theory imputation replaces
distribution-free imputation when there are too few complete cases, and the
chi-squared reference is used for the Neyman statistic in patterns with at
least n_min cases. Setting n_min larger than the largest
pattern simulates the reference for all patterns, as in Jamshidian and Jalal
(2010). This function differs from MissMech in two respects: the
simulated Neyman p-values use , and the
Anderson-Darling p-value is interpolated from the simulated quantiles of the
kSamples package (Scholz and Zhu, 2025) instead of the five critical
values of Scholz and Stephens (1987). P-values can therefore differ from
MissMech, particularly below 0.01. The quantiles cover upper-tail
probabilities from to ; beyond this range the
p-value is extrapolated and nonparametric$extrapolated is
TRUE.
With n_imputations > 1 the tests are repeated on each completed data
set, holding the estimates used for imputation fixed. Jamshidian and Jalal
(2010, Section 6) suggest examining the variability of the p-values and the
pattern-specific results to identify patterns whose covariance differs.
These results are exploratory and are not pooled.
Both tests treat the cases within a pattern as approximately independent,
which Jamshidian and Jalal (2010) and Jamshidian, Jalal and Jansen (2014)
found adequate for patterns with at least four cases. Known groups with
different covariance matrices can cause rejection even under MCAR;
conversely, supplying complete data through imputed_data with each
group given its own artificial pattern tests covariance homogeneity across
the groups (Jamshidian, Jalal and Jansen, 2014, Example 5).
The procedure ignores the marginal regression model and is a screening
diagnostic: failure to reject does not establish MCAR. For longitudinal
geer fits, mcar_logistic_test assesses whether
covariates or previous responses predict missingness.
An object of class c("geer_htest", "htest"). The standard
components hold the statistic and p-value of the selected test. In
addition, the object contains:
tests |
a data frame with the statistics and p-values of the tests for the first imputation. |
hawkins |
the detailed results of the Hawkins test for the first
imputation. With |
nonparametric |
the detailed results of the Anderson-Darling test for
the first imputation, if computed, including the pattern contributions
|
imputations |
a list with the statistics and p-values
( |
n.imputations |
the number of imputed data sets. |
patterns, pattern.counts
|
the retained missingness patterns, with 1 for a missing value, and their numbers of cases. |
omitted.patterns |
the patterns omitted by |
n, p
|
the numbers of retained rows and of variables. |
imputation.requested, imputation.used
|
the requested and the actual
imputation method, |
complete.cases |
the number of retained complete cases. |
imputed.data |
the first completed data set. |
location, covariance
|
the estimates used for imputation, |
em.iterations, em.converged
|
the number of EM iterations and whether
the EM algorithm converged, |
method.requested, selected.test
|
the requested diagnostic and the test giving the primary result. |
alpha |
the significance level of the rule used with
|
interpretation |
a short interpretation of the first imputation. |
Hawkins, D.M. (1981) A new test for multivariate normality and homoscedasticity. Technometrics, 23, 105–110.
Jamshidian, M. and Jalal, S. (2010) Tests of homoscedasticity, normality, and missing completely at random for incomplete multivariate data. Psychometrika, 75, 649–674.
Jamshidian, M., Jalal, S. and Jansen, C. (2014) MissMech: An R package for testing homoscedasticity, multivariate normality, and missing completely at random (MCAR). Journal of Statistical Software, 56, 1–31.
Scholz, F.W. and Stephens, M.A. (1987) K-sample Anderson-Darling tests. Journal of the American Statistical Association, 82, 918–924.
Scholz, F. and Zhu, A. (2025) kSamples: K-Sample Rank Tests and their Combinations. R package version 1.2-12. https://CRAN.R-project.org/package=kSamples
Srivastava, M.S. and Dolatabadi, M. (2009) Multiple imputation and other resampling schemes for imputing missing observations. Journal of Multivariate Analysis, 100, 1919–1937.
mcar_little_test, mcar_logistic_test,
geewa, geewa_binary.
set.seed(1) x <- matrix(rnorm(240), ncol = 3) x[41:60, 3] <- NA x[61:80, 2:3] <- NA mcar_homoscedasticity_test(x, method = "nonparametric") ## Several imputations out <- mcar_homoscedasticity_test(x, method = "nonparametric", n_imputations = 5) out$imputations$testsset.seed(1) x <- matrix(rnorm(240), ncol = 3) x[41:60, 3] <- NA x[61:80, 2:3] <- NA mcar_homoscedasticity_test(x, method = "nonparametric") ## Several imputations out <- mcar_homoscedasticity_test(x, method = "nonparametric", n_imputations = 5) out$imputations$tests
Performs Little's (1988) test of the hypothesis that the missing values are missing completely at random (MCAR).
mcar_little_test( object, data = NULL, maxit = 1000L, tol = 1e-08, reference = c("auto", "asymptotic") )mcar_little_test( object, data = NULL, maxit = 1000L, tol = 1e-08, reference = c("auto", "asymptotic") )
object |
a fitted model object of class |
data |
optional data frame containing the data used to fit
|
maxit |
positive integer giving the maximum number of iterations of the
EM algorithm used to estimate the multivariate normal mean and covariance
matrix. Defaults to |
tol |
a single positive finite number giving the relative convergence
tolerance of the EM algorithm. Defaults to |
reference |
character string specifying the reference distribution:
Little's exact F reference when the data are bivariate monotone and the
chi-squared reference otherwise ( |
Let the rows be grouped into missing-data patterns. For pattern ,
let be its number of rows, the number of observed
variables, and their mean vector. With and
the maximum likelihood estimates of the common mean vector
and covariance matrix under a multivariate normal model, obtained by the EM
algorithm, and , Little's
statistic is
which under MCAR is asymptotically chi-squared with
degrees of freedom, where is the number of variables.
When there are two variables, one fully observed, Little shows that
with . With
reference = "auto" this exact reference is used in that case,
provided the identity is reproduced numerically from the EM estimates;
otherwise a warning is issued and the chi-squared reference is used, which
usually indicates that tol is too loose.
Matrix or data frame input must have at least two rows and two variables,
at least two observed values per variable, at least one jointly observed
value for every pair of variables, and no infinite values. Rows with no
observed values belong to no pattern and are removed with a warning. For a
fitted model object, the response is arranged with one row per cluster and
one column per repeated index; if repeated was not supplied
when fitting, the row order within each cluster defines the occasions.
The test assumes a multivariate normal model and is most appropriate for quantitative variables (Little, 1988), so a warning is issued for binary variables. It is a diagnostic for the missingness mechanism rather than for the fitted mean model (Hardin and Hilbe, 2013): a large p-value does not establish MCAR. Without missing values the statistic is 0 and the p-value 1.
An object of class c("geer_htest", "htest"). In addition to the
standard components, the object contains:
missing.patterns |
the number of distinct missing-data patterns. |
n |
the number of independent rows or clusters tested. |
variables |
the number of variables or repeated measurements tested. |
iterations |
the number of EM iterations used. |
converged |
whether the EM algorithm converged. |
mean |
the maximum-likelihood estimate of the common mean vector. |
covariance |
the degrees-of-freedom-corrected covariance matrix used in Little's statistic. |
ml.covariance |
the uncorrected multivariate-normal maximum-likelihood covariance estimate. |
reference |
the reference distribution used for the reported p-value. |
asymptotic.df |
the degrees of freedom for the large-sample chi-squared reference. |
asymptotic.p.value |
the large-sample chi-squared p-value. |
exact.p.value |
the exact bivariate monotone p-value when available,
otherwise |
exact.f.statistic |
the corresponding bivariate ANOVA F statistic
when available, otherwise |
Hardin, J.W. and Hilbe, J.M. (2013) Generalized Estimating Equations, 2nd Edition. Chapman and Hall/CRC, Boca Raton.
Little, R.J.A. (1988) A test of missing completely at random for multivariate data with missing values. Journal of the American Statistical Association, 83, 1198–1202.
mcar_logistic_test,
mcar_homoscedasticity_test, geewa,
geewa_binary.
x <- data.frame( visit1 = c(2.1, 4.3, 3.2, 5.8, 7.1, 6.4, 8.2, 9.5, 10.1, 11.3), visit2 = c(1.5, 3.8, 2.9, 6.2, NA, 5.1, 8.9, NA, 9.4, 12.0), visit3 = c(3.0, 4.9, NA, 7.1, 6.3, 7.8, NA, 10.2, 11.5, 13.1) ) mcar_little_test(x)x <- data.frame( visit1 = c(2.1, 4.3, 3.2, 5.8, 7.1, 6.4, 8.2, 9.5, 10.1, 11.3), visit2 = c(1.5, 3.8, 2.9, 6.2, NA, 5.1, 8.9, NA, 9.4, 12.0), visit3 = c(3.0, 4.9, NA, 7.1, 6.3, 7.8, NA, 10.2, 11.5, 13.1) ) mcar_little_test(x)
Tests whether the missingness of a longitudinal response depends on the previous response or on observed covariates, using a logistic regression in the spirit of Ridout (1991) and Fitzmaurice, Heath and Clifford (1996) fitted by generalized estimating equations. MCAR is defined as in Rubin (1976).
mcar_logistic_test( object, formula = NULL, data = NULL, orstr = c("independence", "exchangeable", "unstructured"), test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), control = geer_control() )mcar_logistic_test( object, formula = NULL, data = NULL, orstr = c("independence", "exchangeable", "unstructured"), test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), control = geer_control() )
object |
a fitted model object of class |
formula |
optional one-sided formula of fully observed covariates of
missingness, for example |
data |
optional data frame containing the data used to fit
|
orstr |
character string specifying the working odds-ratio structure of
the binary missingness model: |
test |
character string specifying the hypothesis test: Wald
( |
cov_type |
character string specifying the covariance matrix estimator
used for inference: one of the estimators described in
|
pmethod |
character string specifying the approximation to the null
distribution of the modified working tests: Rao-Scott ( |
control |
list of control parameters as returned by
|
For each cluster and occasion , let
. The transitions with
observed form the risk set, on which the model
is fitted by geewa_binary with method = "gee", so that
the missingness indicators of a cluster may be correlated. The occasion
effects are nuisance parameters. The component tests
contains three tests, all computed by the procedure selected by
test:
response_history. Rejection indicates
that missingness depends on the previous response, which is evidence
against covariate-dependent MCAR. This is the primary test.
covariates. Rejection is evidence
against MCAR but is compatible with covariate-dependent MCAR.
overall.
The modified working likelihood ratio test requires
orstr = "independence". With score tests and
cov_type = "jackknife", the covariance component is computed from
the larger model. The small-sample estimators of vcov.geer
are evaluated at the fitted means of the smaller model, which extends their
published definitions.
Under monotone dropout each cluster contributes up to its first missing
response. With intermittent missingness a warning is issued, because the
result is then a local transition diagnostic rather than a dropout test.
Covariates in formula must be fully observed, and measurement rows
that are absent from the data cannot be detected: when no response is
missing but some clusters have no rows for some occasions, a warning is
issued. The test is a
diagnostic: failure to reject does not establish MCAR and does not rule
out dependence on unobserved responses.
An object of class c("geer_htest", "htest"). In addition to the
standard components, the object contains:
tests |
a data frame containing the response-history, covariate, and overall tests using the selected procedure. |
coefficients |
the coefficient table of the binary GEE missingness
model, or |
model |
the fitted model object of class |
formula |
the one-sided covariate formula. |
dropped_covariates |
the model-matrix columns omitted because they are aliased with the occasion effects or with earlier covariate columns. |
missing, observed, transitions
|
the numbers of missing outcomes, observed outcomes, and transitions in the risk set. |
clusters |
the number of clusters represented in the risk set. |
intermittent |
whether an observed response occurs after a missing response for at least one cluster. |
orstr, test, cov_type, pmethod
|
the association structure, testing procedure, covariance estimator, and working-test approximation used for inference. |
Fitzmaurice, G.M., Heath, A.F. and Clifford, P. (1996) Logistic regression models for binary panel data with attrition. Journal of the Royal Statistical Society: Series A, 159, 249–263.
Ridout, M.S. (1991) Testing for random dropouts in repeated measurement data. Biometrics, 47, 1617–1619.
Rubin, D.B. (1976) Inference and missing data. Biometrika, 63, 581–592.
mcar_little_test,
mcar_homoscedasticity_test, geewa,
geewa_binary.
set.seed(1) id <- rep(seq_len(60), each = 4) time <- rep(seq_len(4), times = 60) treatment <- rep(rep(c(0, 1), each = 30), each = 4) y_complete <- 2 + 0.4 * treatment + 0.2 * time + rnorm(length(id)) y <- y_complete for (i in seq_len(60)) { idx <- which(id == i) for (j in 2:4) { p <- plogis(-2.8 + 0.5 * treatment[idx[j]] + 0.45 * y_complete[idx[j - 1]]) if (rbinom(1, 1, p) == 1) { y[idx[j:4]] <- NA_real_ break } } } dat <- data.frame(id, time, treatment, y) fit <- geewa( formula = y ~ treatment + time, family = gaussian(), data = dat, id = id, repeated = time, corstr = "independence" ) out <- mcar_logistic_test(fit, formula = ~ treatment, test = "wald") out out$tests ## Generalized score version of the same diagnostic mcar_logistic_test(fit, formula = ~ treatment, test = "score")set.seed(1) id <- rep(seq_len(60), each = 4) time <- rep(seq_len(4), times = 60) treatment <- rep(rep(c(0, 1), each = 30), each = 4) y_complete <- 2 + 0.4 * treatment + 0.2 * time + rnorm(length(id)) y <- y_complete for (i in seq_len(60)) { idx <- which(id == i) for (j in 2:4) { p <- plogis(-2.8 + 0.5 * treatment[idx[j]] + 0.45 * y_complete[idx[j - 1]]) if (rbinom(1, 1, p) == 1) { y[idx[j:4]] <- NA_real_ break } } } dat <- data.frame(id, time, treatment, y) fit <- geewa( formula = y ~ treatment + time, family = gaussian(), data = dat, id = id, repeated = time, corstr = "independence" ) out <- mcar_logistic_test(fit, formula = ~ treatment, test = "wald") out out$tests ## Generalized score version of the same diagnostic mcar_logistic_test(fit, formula = ~ treatment, test = "score")
Extracts the model matrix of the marginal mean model of a fitted geer
object.
## S3 method for class 'geer' model.matrix(object, ...)## S3 method for class 'geer' model.matrix(object, ...)
object |
a fitted model object of class |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
The matrix is the one stored when the model was fitted, so it agrees with the coefficients, contrasts, and observations used in the fit, and its rows are in the internal order of the fitted model.
The model matrix, with attributes "assign", which maps the columns
to the terms (0 for the intercept), and, for models with factors,
"contrasts".
geewa, geewa_binary,
model.matrix.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(model.matrix(fit))data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(model.matrix(fit))
Plots the sequence of residual signs tested by runs_test, as
in Hardin and Hilbe (2013, Section 4.2.1), with successive runs in
different colors and, under the natural ordering, the cluster boundaries.
## S3 method for class 'geer_runs_test' plot( x, cluster_breaks = NULL, col = NULL, run_colors = grDevices::palette.colors(4L, "Okabe-Ito"), pch = 1L, cex = NULL, main = NULL, sub = NULL, xlab = NULL, ylab = NULL, ... )## S3 method for class 'geer_runs_test' plot( x, cluster_breaks = NULL, col = NULL, run_colors = grDevices::palette.colors(4L, "Okabe-Ito"), pch = 1L, cex = NULL, main = NULL, sub = NULL, xlab = NULL, ylab = NULL, ... )
x |
an object of class |
cluster_breaks |
logical indicating whether dotted lines mark the
boundaries between clusters. Defaults to |
col |
color of the symbols. Defaults to |
run_colors |
vector of at least three colors, recycled across
successive runs. Defaults to
|
pch |
plotting symbol, passed to |
cex |
symbol size, passed to |
main, sub, xlab, ylab
|
character strings giving the title, subtitle, and
axis labels. Defaults to |
... |
further named graphical parameters passed to
|
Each tested residual is plotted at or against its
position in the tested sequence; zero residuals are excluded and their
number is given in the default subtitle. The default title gives the
ordering, and the default subtitle the number of runs, its null
expectation, and the p-value. At least three colors are needed, because
with two the color would simply repeat the sign. Cluster boundaries are
meaningful only under the natural ordering, and requesting them otherwise
gives a warning.
Invisibly, a data frame with one row per tested residual and columns
position, sign, run, and cluster.
Hardin, J.W. and Hilbe, J.M. (2013) Generalized Estimating Equations, 2nd Edition. Chapman and Hall/CRC, Boca Raton.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) plot(runs_test(fit)) plot(runs_test(fit, order_by = "fitted"), ylim = c(-2, 2))data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) plot(runs_test(fit)) plot(runs_test(fit, order_by = "fitted"), ylim = c(-2, 2))
Generates predictions from a fitted geer object, optionally with
approximate standard errors.
## S3 method for class 'geer' predict( object, newdata = NULL, type = c("link", "response"), cov_type = "bias-corrected", se.fit = FALSE, ... )## S3 method for class 'geer' predict( object, newdata = NULL, type = c("link", "response"), cov_type = "bias-corrected", se.fit = FALSE, ... )
object |
a fitted model object of class |
newdata |
optional data frame containing the variables used for
prediction. Defaults to |
type |
character string specifying the scale of the predictions: linear
predictor ( |
cov_type |
character string specifying the covariance matrix estimator
used for the standard errors when |
se.fit |
logical indicating whether standard errors are returned.
Defaults to |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
The linear predictor is computed from the model matrix of newdata,
or of the fitted data, and the offset, and transformed by the inverse link
for type = "response". Standard errors are obtained by the delta
method. When newdata is supplied and the model has an offset, the
variables of the offset must be in newdata.
For se.fit = FALSE, a numeric vector of predictions. For
se.fit = TRUE, a list with components:
fit |
the predictions. |
se.fit |
their standard errors. |
With newdata, the results are named by its row names; otherwise they
are unnamed.
With newdata, the predictions follow its rows, and rows with missing
values give NA. Without it, they follow the internal order of the
fitted model: the complete cases, sorted by cluster and, within cluster, by
repeated. To obtain predictions in the order of the data, supply the
data as newdata.
fitted.geer, residuals.geer,
geewa, geewa_binary,
predict.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(predict(fit)) head(predict(fit, type = "response")) ## Predictions for new data, with standard errors pred <- predict(fit, newdata = cerebrovascular[1:5, ], type = "response", se.fit = TRUE) preddata("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(predict(fit)) head(predict(fit, type = "response")) ## Predictions for new data, with standard errors pred <- predict(fit, newdata = cerebrovascular[1:5, ], type = "response", se.fit = TRUE) pred
Prints the call, the estimated regression coefficients, and the
convergence information of a fitted geer object.
## S3 method for class 'geer' print(x, ...)## S3 method for class 'geer' print(x, ...)
x |
a fitted model object of class |
... |
additional arguments passed to or from other methods. Currently unused. |
The input object x is returned invisibly.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) print(fit)data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) print(fit)
Prints a summary.geer object: the call, the estimation method, the
sample and cluster sizes, the coefficient table, the dispersion parameter,
and the working association structure.
## S3 method for class 'summary.geer' print(x, ...)## S3 method for class 'summary.geer' print(x, ...)
x |
an object of class |
... |
additional arguments passed to or from other methods. Currently unused. |
The input object x is returned invisibly.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) print(summary(fit))data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) print(summary(fit))
Extracts residuals of different types from a fitted geer object.
## S3 method for class 'geer' residuals( object, type = c("working", "pearson", "deviance", "mahalanobis", "response"), ... )## S3 method for class 'geer' residuals( object, type = c("working", "pearson", "deviance", "mahalanobis", "response"), ... )
object |
a fitted model object of class |
type |
character string specifying the type of residuals: raw
( |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
With prior weights , the Pearson and deviance residuals are
where is the weighted deviance contribution of the family, as
in glmtoolbox (Vanegas, Rondon and Paula, 2023). The Mahalanobis
residual of cluster is
where is the fitted working covariance matrix, including the
dispersion. It is a nonnegative cluster-level diagnostic.
A numeric vector with one value per observation, in the order given under
Observation order, or, for type = "mahalanobis", one value per
cluster, named by the cluster identifier.
The values follow the internal order of the fitted model: the complete
cases, sorted by cluster and, within cluster, by repeated. Unless the
data were already in this order and had no missing values, assigning the
values to the data, as in data$r <- residuals(fit), misaligns the
rows without warning. fit$id and fit$repeated are stored in
the same order and can be used to align them.
Vanegas, L.H., Rondon, L.M. and Paula, G.A. (2023) Generalized Estimating Equations using the new R package glmtoolbox. The R Journal, 15, 105–133.
fitted.geer, predict.geer,
runs_test, geewa, geewa_binary,
residuals.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(residuals(fit)) head(residuals(fit, type = "pearson")) head(residuals(fit, type = "deviance")) head(residuals(fit, type = "mahalanobis"))data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) head(residuals(fit)) head(residuals(fit, type = "pearson")) head(residuals(fit, type = "deviance")) head(residuals(fit, type = "mahalanobis"))
Data from a randomized clinical trial on respiratory illness.
respiratoryrespiratory
A data frame with 444 rows and 8 columns:
integer subject identifier.
integer follow-up visit identifier.
binary indicator of respiratory status, 0 = poor and 1 = good.
factor with levels placebo and active.
binary indicator of baseline respiratory status, 0 = poor and 1 = good.
numeric age in years recorded at baseline.
factor with levels female and male.
factor with levels C1 and C2.
One hundred eleven subjects from two clinical centers were enrolled in a randomized clinical trial, yielding 444 observations (four follow-up visits per subject). Subjects were randomly assigned to treatment groups. Baseline examinations were conducted before treatment began. After treatment, subjects were examined at four scheduled follow-up visits.
Stokes, M.E., Davis, C.S. and Koch, G.G. (1995) Categorical Data Analysis using the SAS System. SAS Institute, Cary.
data("respiratory", package = "geer") str(respiratory)data("respiratory", package = "geer") str(respiratory)
Data from a randomized clinical trial on the efficacy of mouth rinses in reducing dental plaque.
rinserinse
A data frame with 218 rows and 8 columns:
integer subject identifier.
integer follow-up month identifier.
numeric plaque score.
factor indicating the rinse group, with levels
placebo, A, and B.
numeric plaque score at baseline.
factor with levels female and male.
numeric age in years recorded at baseline.
factor with levels no and yes.
One hundred nine adults aged 18–55 with pre-existing dental plaque but without advanced periodontal disease were enrolled in a randomized, double-blind clinical trial, yielding 218 follow-up observations (up to two follow-up assessments per subject). Subjects were assigned to one of two novel mouth rinses (A or B) or to a control mouth rinse. Eligibility required at least 20 sound natural teeth and a mean plaque index of 2.0 or greater. Plaque was assessed at baseline, 3 months, and 6 months using the Turesky modification of the Quigley-Hein index. Four subjects had missing plaque scores. The trial aimed to evaluate the effectiveness of the three rinses in inhibiting dental plaque.
Hadgu, A. and Koch, G. (1999) Application of generalized estimating equations to a dental randomized clinical trial. Journal of Biopharmaceutical Statistics, 9, 161–178.
data("rinse", package = "geer") str(rinse)data("rinse", package = "geer") str(rinse)
Performs the nonparametric Wald-Wolfowitz runs test proposed by Chang (2000) for detecting non-random patterns in residuals from a fitted generalized estimating equation model.
runs_test( object, order_by = "natural", alternative = c("two.sided", "less", "greater") )runs_test( object, order_by = "natural", alternative = c("two.sided", "less", "greater") )
object |
a fitted model object of class |
order_by |
character string or numeric vector specifying the order of
the residuals: by cluster and |
alternative |
character string specifying the alternative hypothesis:
|
Let and be the numbers of positive and negative
residuals and the number of runs in their sign sequence. Under the
null hypothesis that the signs occur in random order,
and is compared with the standard normal
distribution without continuity correction, as in Chang (2000) and Hardin
and Hilbe (2013). Chang (2000) recommends the approximation only when
and ; otherwise a warning is issued.
alternative = "less" tests against too few runs, as produced by
clustered signs, an unmodeled trend, or omitted structure, and
"greater" against too many runs, that is, alternating signs. Chang
(2000) rejects for extreme in either direction, which corresponds
to the two-sided default. Hardin and Hilbe (2013) report one-sided p-values
in the direction of the observed .
Only the signs of the residuals are used. The working, Pearson, and
deviance residuals have the same signs, so the test does not depend on the
residual type. Zero residuals are omitted and counted in the zero
component. Prior weights are ignored: each observation contributes one sign.
A character order_by that is not "natural", "fitted",
or a model matrix column is looked up in the data used to fit the model,
so a covariate omitted from the model can be used. The model frame is
rebuilt from the call and checked against the stored clusters and
occasions; an error is signaled if the variable adds missing values or the
check fails, in which case an aligned numeric vector can be supplied
instead. Factor, character, and logical variables are ordered by their
codes, and date-time variables by their numeric values.
An object of class c("geer_runs_test", "geer_htest", "htest"), which
can be plotted with plot.geer_runs_test. The standard
components hold (statistic), and
(parameter), (estimate), and
(null.value). In addition, the object contains:
runs |
the observed number of runs, |
expected_runs |
the null expectation |
variance_runs |
the null variance |
positive |
the number of positive residuals, |
negative |
the number of negative residuals, |
zero |
the number of zero residuals omitted from the test. |
nonzero |
the number of residuals used in the test. |
order_by |
a description of the ordering used. |
natural_order |
a logical value indicating whether the natural cluster/repeated ordering was used. |
signs |
the sign sequence whose runs were counted, in the order tested and with zero residuals removed. |
cluster |
the cluster identifier of each element of |
The null distribution does not depend on the ordering; the ordering determines the alternative. Ordering by a variable gives power against signs that depend on that variable:
"natural"signs that are grouped within clusters or drift over time;
"fitted"signs that depend on the fitted mean, suggesting an inadequate link or variance function;
a misspecified functional form of that covariate;
a wrongly omitted covariate;
whatever the vector indexes, such as batch or center.
Chang (2000) and Hardin and Hilbe (2013, Section 4.2.1) use the natural ordering, and Hardin and Hilbe also order by a covariate; ordering by fitted values or by a supplied vector is an extension.
Under the natural ordering, too few runs can arise from positive within-cluster association as well as from a misspecified mean, so a rejection does not identify the cause. Orderings that vary within clusters interleave the clusters and make a rejection more readily attributable to the mean structure. A cluster-level covariate, such as treatment arm, keeps the clusters together and behaves like the natural ordering.
Ties in the ordering are broken by the natural order, so a heavily tied ordering, such as fitted values from few covariate patterns or a factor with few levels, approaches the natural ordering.
Hardin and Hilbe (2013, Section 4.2.1) print for their
second example under the natural ordering; the correct value is
, which gives instead of
.
Chang, Y.-C. (2000) Residuals analysis of the generalized linear models for longitudinal data. Statistics in Medicine, 19, 1277–1293.
Hardin, J.W. and Hilbe, J.M. (2013) Generalized Estimating Equations, 2nd Edition. Chapman and Hall/CRC, Boca Raton.
plot.geer_runs_test, residuals.geer,
fitted.geer, predict.geer.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) runs_test(fit) runs_test(fit, order_by = "fitted") runs_test(fit, order_by = "lnage") runs_test(fit, alternative = "less")data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) runs_test(fit) runs_test(fit, order_by = "fitted") runs_test(fit, order_by = "lnage") runs_test(fit, alternative = "less")
Performs stepwise model selection for a fitted geer object, moving at
each step to the single-term addition or deletion that most reduces a
quasi-likelihood or Gaussian pseudolikelihood information criterion.
step_criterion( object, scope, direction = c("backward", "forward", "both"), criterion = c("QICu", "QIC", "QICC", "AGPC", "SGPC"), cov_type = "robust", steps = 1000, trace = FALSE )step_criterion( object, scope, direction = c("backward", "forward", "both"), criterion = c("QICu", "QIC", "QICC", "AGPC", "SGPC"), cov_type = "robust", steps = 1000, trace = FALSE )
object |
a fitted model object of class |
scope |
optional formula, or list with components |
direction |
character string specifying the direction of the search:
|
criterion |
character string specifying the information criterion
minimized in the search: |
cov_type |
character string specifying the covariance matrix estimator
used in the penalty terms of |
steps |
nonnegative integer giving the maximum number of steps. Defaults
to |
trace |
logical indicating whether the candidate table of each step is
printed during the search. Defaults to |
The criteria are those of geecriteria that are intended for
comparing mean models: QIC and QICu (Pan, 2001), QICC
(Hardin and Hilbe, 2013), and AGPC and SGPC (Carey and Wang,
2011; Fu, Hao and Wang, 2018), as used for variable selection by
glmtoolbox (Vanegas, Rondon and Paula, 2023). The criteria that
geecriteria provides for selecting the working association
structure, such as CIC, are not accepted.
The initial model must contain every term of scope$lower, and
scope$upper every term of the initial model. At each step every
candidate model, obtained by adding a term of scope$upper or deleting
a term not in scope$lower, is refitted to the rows used by
object, as described in add1.geer. The association and
dispersion parameters are re-estimated for each candidate. With
direction = "backward" only deletions, with "forward" only
additions, and with "both" additions and deletions together are
considered. The candidate with the smallest value of the criterion is
selected, the first in the order of the terms of the scope in case of a
tie, and the search moves to it only if its value is smaller than that of
the current model by more than
sqrt(.Machine$double.eps) * max(1, abs(value)), so that differences
within the convergence tolerance of the refits do not decide a move. Moves
respect marginality. The search stops when no candidate improves the
criterion or after steps steps. Because each move decreases the
criterion, no model is visited twice. A candidate whose criterion cannot be
evaluated is skipped.
Each step refits every candidate model, but a model already fitted during
the search, such as the model before the previous move when
direction = "both", is not refitted. With
cov_type = "jackknife" and criterion = "QIC" or "QICC",
every candidate model is in addition refitted once per cluster, which can be
slow.
The quasi-likelihood in QIC, QICu, and QICC diverges
when a fitted mean reaches the boundary of its support, so these criteria
should not be used when only some of the candidate models reach the
boundary. Refits of such candidates warn about fitted probabilities or
rates near the boundary. See geecriteria.
The selected model, a fitted model object of class "geer" with an
additional component anova of class c("geer_anova", "anova",
"data.frame") with one row for the initial model and one for each step,
whose row names give the term added or removed, and columns Step
(NA for the initial model), Df, and the value of the
criterion, named after it, and an additional component candidates,
a list with one table of class c("geer_anova", "anova",
"data.frame") per step. Each table has one row for the current model
(<none>) and one for each candidate, sorted by the criterion, and
columns Df and the value of the criterion. The last table is that of
the step at which the search stopped, unless it stopped at the step limit.
Carey, V.J. and Wang, Y.G. (2011) Working covariance model selection for generalized estimating equations. Statistics in Medicine, 30, 3117–3124.
Fu, L., Hao, Y. and Wang, Y.G. (2018) Working correlation structure selection in generalized estimating equations. Computational Statistics, 33, 983–996.
Hardin, J.W. and Hilbe, J.M. (2013) Generalized Estimating Equations, 2nd Edition. Chapman and Hall/CRC, Boca Raton.
Pan, W. (2001) Akaike's information criterion in generalized estimating equations. Biometrics, 57, 120–125.
Vanegas, L.H., Rondon, L.M. and Paula, G.A. (2023) Generalized Estimating Equations using the new R package glmtoolbox. The R Journal, 15, 105–133.
step_p, geecriteria,
add1.geer, drop1.geer, geewa,
geewa_binary.
data("respiratory", package = "geer") respiratory2 <- respiratory[respiratory$center == "C2", ] fit <- geewa_binary( formula = status ~ baseline + treatment + gender + visit + age, link = "probit", data = respiratory2, id = id, repeated = visit, method = "pgee-jeffreys" ) ## Backward elimination by QICu step_criterion(fit) ## Bidirectional selection by QIC within a scope step_criterion( fit, scope = list( lower = ~ baseline + treatment, upper = ~ (baseline + treatment + gender + visit + age)^2 ), direction = "both", criterion = "QIC" )data("respiratory", package = "geer") respiratory2 <- respiratory[respiratory$center == "C2", ] fit <- geewa_binary( formula = status ~ baseline + treatment + gender + visit + age, link = "probit", data = respiratory2, id = id, repeated = visit, method = "pgee-jeffreys" ) ## Backward elimination by QICu step_criterion(fit) ## Bidirectional selection by QIC within a scope step_criterion( fit, scope = list( lower = ~ baseline + treatment, upper = ~ (baseline + treatment + gender + visit + age)^2 ), direction = "both", criterion = "QIC" )
Performs stepwise model selection for a fitted geer object using
repeated single-term additions (add1.geer) and deletions
(drop1.geer), with candidate moves evaluated by hypothesis
tests.
step_p( object, scope, direction = c("backward", "forward", "both"), p_enter = 0.15, p_remove = 0.15, test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), steps = 1000 )step_p( object, scope, direction = c("backward", "forward", "both"), p_enter = 0.15, p_remove = 0.15, test = c("wald", "score", "working-wald", "working-score", "working-lrt"), cov_type = "bias-corrected", pmethod = c("rao-scott", "satterthwaite"), steps = 1000 )
object |
a fitted model object of class |
scope |
optional formula, or list with components |
direction |
character string specifying the direction of the search:
|
p_enter |
a single number strictly between 0 and 1 giving the p-value
threshold for adding a term. It must not exceed |
p_remove |
a single number strictly between 0 and 1 giving the p-value
threshold for removing a term. Defaults to |
test |
character string specifying the hypothesis test: Wald
( |
cov_type |
character string specifying the covariance matrix estimator
used for inference: one of the estimators described in
|
pmethod |
character string specifying the approximation to the null
distribution of the modified working tests: Rao-Scott ( |
steps |
nonnegative integer giving the maximum number of steps. Defaults
to |
step_p() repeatedly calls add1.geer and
drop1.geer. The terms of scope$lower are always kept,
and scope$upper defines the largest model considered. A single
formula is taken as upper, with an empty lower. The initial
model must contain every term of scope$lower, and scope$upper
every term of the initial model. Moves respect marginality. With
direction = "both", a deletion is tried first at each step and an
addition only if no deletion qualifies. The search stops when no move meets
its p-value threshold, after steps steps, or when a move would return
to a model already visited.
The tests are described in anova.geer. The CIC column is
computed with cov_type, so cov_type = "jackknife" refits every
candidate model once per cluster and can be slow. Candidate models are
refitted to the rows used by object, as described in
add1.geer.
The selected model, a fitted model object of class "geer" with an
additional component anova of class c("geer_anova", "anova",
"data.frame") with one row for the initial model and one for each step,
whose row names give the term added or removed, and columns Step
(NA for the initial model), Df, Chi, Pr(>Chi),
and CIC.
Rotnitzky, A. and Jewell, N.P. (1990) Hypothesis testing of regression parameters in semiparametric generalized linear models for cluster correlated data. Biometrika, 77, 485–497.
step_criterion, add1.geer,
drop1.geer, anova.geer,
geecriteria, geewa,
geewa_binary.
data("respiratory", package = "geer") respiratory2 <- respiratory[respiratory$center == "C2", ] fit <- geewa_binary( formula = status ~ (baseline + treatment + gender + visit + age)^2, link = "probit", data = respiratory2, id = id, repeated = visit, method = "pgee-jeffreys" ) ## Backward elimination step_p(fit, p_remove = 0.10) ## Bidirectional selection within a scope step_p( fit, scope = list( lower = ~ baseline + treatment, upper = ~ (baseline + treatment + gender + visit + age)^2 ), direction = "both", p_enter = 0.10, test = "score", cov_type = "robust" )data("respiratory", package = "geer") respiratory2 <- respiratory[respiratory$center == "C2", ] fit <- geewa_binary( formula = status ~ (baseline + treatment + gender + visit + age)^2, link = "probit", data = respiratory2, id = id, repeated = visit, method = "pgee-jeffreys" ) ## Backward elimination step_p(fit, p_remove = 0.10) ## Bidirectional selection within a scope step_p( fit, scope = list( lower = ~ baseline + treatment, upper = ~ (baseline + treatment + gender + visit + age)^2 ), direction = "both", p_enter = 0.10, test = "score", cov_type = "robust" )
Summarizes a fitted geer object, with a table of the coefficients,
their standard errors, z-statistics, and p-values.
## S3 method for class 'geer' summary(object, cov_type = "bias-corrected", ...)## S3 method for class 'geer' summary(object, cov_type = "bias-corrected", ...)
object |
a fitted model object of class |
cov_type |
character string specifying the covariance matrix estimator
used for the standard errors, z-statistics, and p-values: one of the
estimators described in |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
An object of class "summary.geer", a list with components:
coefficients |
a matrix with columns |
family |
the |
alpha |
the estimated or fixed association parameters. |
call |
the matched call. |
residuals |
the working residuals. |
obs_no |
the number of observations used in the fit. |
clusters_no |
the number of clusters used in the fit. |
min_cluster_size |
the smallest observed cluster size. |
max_cluster_size |
the largest observed cluster size. |
iter |
the number of iterations used. |
converged |
logical indicating whether the algorithm converged. |
phi |
the estimated or fixed dispersion parameter, 1 for
|
association_structure |
the name of the working association structure. |
method |
character string identifying the estimation method used. |
cov_type |
the covariance estimator used for standard errors. |
print.summary.geer, tidy.geer,
glance.geer, vcov.geer.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) summary(fit) summary(fit, cov_type = "robust")data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) summary(fit) summary(fit, cov_type = "robust")
Summarizes the regression coefficients of a fitted geer object in a
data frame with one row per coefficient, following the conventions of
broom (Robinson, Hayes and Couch, 2024).
## S3 method for class 'geer' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, cov_type = "bias-corrected", ... )## S3 method for class 'geer' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, cov_type = "bias-corrected", ... )
x |
a fitted model object of class |
conf.int |
logical indicating whether Wald confidence limits are
included. Defaults to |
conf.level |
a single number strictly between 0 and 1 specifying the
confidence level. Defaults to |
exponentiate |
logical indicating whether the estimates and confidence
limits are exponentiated, for example to obtain odds ratios. Defaults to
|
cov_type |
character string specifying the covariance matrix estimator
used for the standard errors, z-statistics, and confidence intervals: one
of the estimators described in |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
A data frame, a tibble if tibble is installed, with columns:
term |
the name of the coefficient. |
estimate |
the estimate, exponentiated if |
std.error |
the standard error, on the original scale. |
statistic |
the Wald z-statistic, on the original scale. |
p.value |
the two-sided p-value. |
conf.low, conf.high
|
the confidence limits, if
|
Robinson, D., Hayes, A. and Couch, S. (2024) broom: Convert Statistical Objects into Tidy Tibbles. R package. https://broom.tidymodels.org/
glance.geer, vcov.geer,
confint.geer, geewa,
geewa_binary.
data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) tidy(fit) tidy(fit, conf.int = TRUE, exponentiate = TRUE) tidy(fit, cov_type = "robust")data("epilepsy", package = "geer") fit <- geewa( formula = seizures ~ treatment + lnbaseline + lnage, family = poisson(link = "log"), data = epilepsy, id = id, repeated = visit, corstr = "exchangeable" ) tidy(fit) tidy(fit, conf.int = TRUE, exponentiate = TRUE) tidy(fit, cov_type = "robust")
Extracts the variance-covariance matrix of the estimated regression
parameters from a fitted geer object.
## S3 method for class 'geer' vcov(object, cov_type = "bias-corrected", ...)## S3 method for class 'geer' vcov(object, cov_type = "bias-corrected", ...)
object |
a fitted model object of class |
cov_type |
character string specifying the covariance matrix estimator
used for inference: |
... |
not used. Supplying any argument is an error, so that a misspelled argument name is reported rather than silently ignored. |
Let be the number of clusters, the number of regression
parameters, the derivative of the mean vector of cluster
with respect to the regression parameters, its working covariance
matrix, its vector of response residuals,
,
, and
.
The covariance estimator is selected by cov_type:
"bias-corrected"the bias-corrected sandwich estimator of Morel, Bokossa and Neerchal (2003).
"robust"the sandwich estimator of Liang and Zeger (1986),
with
.
"df-adjusted"the sandwich estimator with the degrees-of-freedom adjustment of MacKinnon and White (1985).
"jackknife"the leave-one-cluster-out jackknife estimator.
"naive"the model-based estimator of Liang and Zeger (1986).
"kauermann-carroll"Kauermann and Carroll (2001): the
robust estimator with replaced by
, using the principal
matrix square root.
"mancl-derouen"Mancl and DeRouen (2001): the robust
estimator with replaced by
.
"ford-westgate"Ford and Westgate (2017): the average of the Kauermann-Carroll and Mancl-DeRouen estimators.
"fay-graubard"Fay and Graubard (2001): the robust
estimator with replaced by , where is
diagonal with entries
and .
"fan-zhang-zhang"Fan, Zhang and Zhang (2013): the robust
estimator with replaced by
, pre- and post-multiplied by
.
"pan"Pan (2001): the residual outer products are pooled
over clusters after standardization by
, so that is replaced by with
.
"gosho-sato-takeuchi"Gosho, Sato and Takeuchi (2014): the
Pan estimator multiplied by .
"wang-long"Wang and Long (2011): the Pan estimator with
replaced by in
.
"westgate-burchett"Westgate and Burchett (2016): the Pan
estimator with replaced by
in . With
instead, the Mancl-DeRouen
version of this estimator, it coincides with the Wang-Long estimator.
The estimators are evaluated at the estimates of the fitted model, whatever
the estimation method, and for any family and link, with and
as used by geewa or geewa_binary. In
the Pan, Gosho-Sato-Takeuchi, Wang-Long, and Westgate-Burchett estimators,
contains the scale parameter and the prior weights, so that
weighted fits are standardized by the marginal variances they assume. The
scale parameter cancels in the sandwich. With unit prior weights and the
logit link, the nine small-sample estimators reproduce those of the same
name in the geessbin package, which standardizes by
.
The bias-corrected, degrees-of-freedom adjusted, and Gosho-Sato-Takeuchi
estimators require more clusters than regression parameters: otherwise the
bias-corrected estimator is NA and the other two give an error. The
Pan, Gosho-Sato-Takeuchi, Wang-Long, and Westgate-Burchett estimators pool
the clusters and require a balanced design, in which every cluster observes
each repeated position once: otherwise they give an error.
The score-type tests of anova.geer, add1.geer,
drop1.geer, step_p, and
mcar_logistic_test evaluate the selected estimator at the fit
of the smaller model, with and of the larger model. For
the nine small-sample estimators this is an extension of the published
estimators, which are defined at the full-model fit. The jackknife estimator
is the exception: score-type tests use the jackknife estimator of the larger
model.
With clusters and the estimate obtained after
deleting cluster , the jackknife estimator is
Each is a full refit by the original estimation
method, not a one-step approximation, with the working association
parameters held at their full-data estimates. The dispersion is
re-estimated if it was estimated in the original fit. For the two-stage
methods ("bcgee-*", "opgee-jeffreys", and
"hpgee-jeffreys") the first stage is repeated in each refit. At
least two clusters are required, and an error is signaled if a refit does
not converge. The jackknife and the nine small-sample estimates are cached
in the fitted object.
A square numeric matrix of estimated covariances between regression
coefficients. Rows and columns are named according to the coefficient names
returned by coef.geer.
Fan, C., Zhang, D. and Zhang, C.H. (2013) A comparison of bias-corrected covariance estimators for generalized estimating equations. Journal of Biopharmaceutical Statistics, 23, 1172–1187.
Fay, M.P. and Graubard, B.I. (2001) Small-sample adjustments for Wald-type tests using sandwich estimators. Biometrics, 57, 1198–1206.
Ford, W.P. and Westgate, P.M. (2017) Improved standard error estimator for maintaining the validity of inference in cluster randomized trials with a small number of clusters. Biometrical Journal, 59, 478–495.
Gosho, M., Sato, T. and Takeuchi, H. (2014) Robust covariance estimator for small-sample adjustment in the generalized estimating equations: a simulation study. Science Journal of Applied Mathematics and Statistics, 2, 20–25.
Kauermann, G. and Carroll, R.J. (2001) A note on the efficiency of sandwich covariance matrix estimation. Journal of the American Statistical Association, 96, 1387–1396.
Liang, K.Y. and Zeger, S.L. (1986) Longitudinal data analysis using generalized linear models. Biometrika, 73, 13–22.
MacKinnon, J.G. and White, H. (1985) Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties. Journal of Econometrics, 29, 305–325.
Mancl, L.A. and DeRouen, T.A. (2001) A covariance estimator for GEE with improved small-sample properties. Biometrics, 57, 126–134.
Morel, J.G., Bokossa, M.C. and Neerchal, N.K. (2003) Small sample correction for the variance of GEE estimators. Biometrical Journal, 45, 395–409.
Pan, W. (2001) On the robust variance estimator in generalised estimating equations. Biometrika, 88, 901–906.
Wang, M. and Long, Q. (2011) Modified robust variance estimator for generalized estimating equations with improved small-sample performance. Statistics in Medicine, 30, 1278–1291.
Westgate, P.M. and Burchett, W.W. (2016) Improving power in small-sample longitudinal studies when using generalized estimating equations. Statistics in Medicine, 35, 3733–3744.
coef.geer, confint.geer,
summary.geer, tidy.geer.
data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) vcov(fit) vcov(fit, cov_type = "robust") vcov(fit, cov_type = "kauermann-carroll")data("cerebrovascular", package = "geer") fit <- geewa_binary( formula = ecg ~ treatment + factor(period), link = "logit", data = cerebrovascular, id = id, repeated = period, orstr = "exchangeable" ) vcov(fit) vcov(fit, cov_type = "robust") vcov(fit, cov_type = "kauermann-carroll")