| Title: | Multiple Imputation Using the General Location Model with the EMB Algorithm |
|---|---|
| Description: | Provides multiple imputation for mixed continuous and categorical data using the General Location Model (Olkin & Tate 1961; Little & Schluchter 1987) combined with the Expectation-Maximization with Bootstrapping (EMB) algorithm. Categorical variables are specified via the noms option; all other variables are treated as continuous. The package wraps the EM implementation in the 'mix' package and extends it with a bootstrap wrapper to produce proper multiple imputations in the sense of Rubin (1987). |
| Authors: | Paul Allison [aut, cre] |
| Maintainer: | Paul Allison <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.3 |
| Built: | 2026-10-16 09:10:49 UTC |
| Source: | https://github.com/pauldallison/glemb |
Converts a glemb object to the mids format used by the mice package,
enabling use of mice::pool() for results pooling.
as.mids.glemb(x, data, ...)as.mids.glemb(x, data, ...)
x |
A |
data |
The original incomplete data frame that was passed to |
... |
Ignored. |
The function stacks the original data (as imputation 0) and all m
imputed datasets in long format, adds .imp and .id columns, and
calls mice::as.mids() to construct the mids object.
A mids object.
glemb() performs multiple imputation of mixed continuous and categorical
data using the General Location Model (GLM) combined with the
Expectation-Maximization with Bootstrapping (EMB) algorithm.
glemb( data, m = 20L, noms = NULL, idvars = NULL, cat.interact = 2L, cat.prior = NULL, empri = NULL, maxits = 1000L, seed = NULL, output = "mids", max.cells = 500000L, meanmodel = "main", p2s = 1L )glemb( data, m = 20L, noms = NULL, idvars = NULL, cat.interact = 2L, cat.prior = NULL, empri = NULL, maxits = 1000L, seed = NULL, output = "mids", max.cells = 500000L, meanmodel = "main", p2s = 1L )
data |
A data frame containing the data to be imputed. All variables
not listed in |
m |
Positive integer. Number of imputed datasets to generate.
Default is |
noms |
Variable names to treat as categorical (nominal) in the
imputation model. Can be supplied quoted or unquoted:
|
idvars |
Character vector of column names to be carried through to the
output unchanged but excluded from the imputation model. Typically used
for subject or case identifiers. Default is |
cat.interact |
Integer, either |
cat.prior |
Numeric scalar or |
empri |
Numeric scalar or |
maxits |
Positive integer. Maximum number of ECM iterations allowed
per bootstrap sample. Default is |
seed |
Positive integer or |
output |
Character scalar. |
max.cells |
Positive integer or |
meanmodel |
Character scalar. Controls the parameterisation of the
within-cell continuous variable means. |
p2s |
Integer, |
The General Location Model (Olkin & Tate 1961; Little & Schluchter 1987) factorises the joint distribution of continuous variables y and categorical variables x as:
The categorical margin is modelled with a log-linear
model restricted to at most cat.interact-way interactions among the
categorical variables. The continuous conditional
is multivariate normal with a
covariance matrix shared across all cells. How the cell means are
parameterised depends on meanmodel. With "main" (default) the mean of
each continuous variable depends on an intercept plus the main effects of
the categorical variables — the same parameterisation as a standard
regression with dummy variables. With "saturated" each cell has its own
unrestricted mean vector. Both models imply that the conditional mean of
every continuous variable is a linear function of all other variables; the
saturated model additionally allows all interactions among the categorical
variables to enter the means. The conditional distribution of every
categorical variable is a logistic regression function of all the other
variables.
Proper multiple imputations are generated via the EMB algorithm (Honaker, King & Blackwell 2011):
Draw a bootstrap sample (with replacement) from the incomplete data.
Run the ECM algorithm (mix::ecm.mix()) on the bootstrap sample to
obtain parameter estimates.
Draw one set of imputed values from the posterior predictive
distribution given those parameters (mix::imp.mix()).
Repeat steps 1–3 m times to produce m completed datasets.
When the number of cells in the multiway table for the categorical variables
is large relative to sample size, some cells may contain few or no
observations. A Dirichlet prior (controlled by cat.prior) is applied by
adding cat.prior pseudo-observations per cell to the bootstrap sample
before estimation. glemb() warns when the number of cells exceeds
n / 5.
An object of class "glemb", which is a list with components:
imputationsA list of m completed data frames.
mNumber of imputations.
callThe matched call.
categoricalNames of variables treated as categorical.
continuousNames of variables treated as continuous.
idvarsNames of ID variables excluded from the imputation model.
cat.interactInteraction order used in the log-linear model.
cat.priorDirichlet pseudocount used (after automatic selection if applicable).
empriRidge prior strength used (after automatic selection if applicable).
maxitsMaximum ECM iterations per bootstrap sample.
seedSeed used, or NULL.
meanmodelMean model used: "main" or "saturated".
Olkin, I. & Tate, R.F. (1961). Multivariate correlation models with mixed discrete and continuous variables. Annals of Mathematical Statistics, 32, 448–465.
Little, R.J.A. & Schluchter, M.D. (1987). Maximum likelihood estimation for mixed continuous and categorical data with missing values. Biometrika, 74, 165–173.
Honaker, J., King, G. & Blackwell, M. (2011). Amelia II: A program for missing data. Journal of Statistical Software, 45(7), 1–47.
Schafer, J.L. (1997). Analysis of Incomplete Multivariate Data. Chapman & Hall.
print.glemb(), summary.glemb(), as.mids.glemb()
## Not run: # Basic usage — specify categorical variables with noms (unquoted names) imp <- glemb(mydata, m = 20, noms = c(race, gender), seed = 123) # Equivalent using quoted names imp <- glemb(mydata, m = 20, noms = c("race", "gender"), seed = 123) # Access the third imputed dataset imp$imputations[[3]] # Allow three-way interactions among categorical variables imp <- glemb(mydata, m = 20, noms = c(race, gender), cat.interact = 3, seed = 123) # Exclude a subject ID from the imputation model imp <- glemb(mydata, m = 20, noms = c(race, gender), idvars = "subject_id", seed = 123) # Use a saturated mean model (cell-specific intercepts; more flexible, # requires more data) imp <- glemb(mydata, m = 20, noms = c(race, gender), meanmodel = "saturated", seed = 123) ## End(Not run)## Not run: # Basic usage — specify categorical variables with noms (unquoted names) imp <- glemb(mydata, m = 20, noms = c(race, gender), seed = 123) # Equivalent using quoted names imp <- glemb(mydata, m = 20, noms = c("race", "gender"), seed = 123) # Access the third imputed dataset imp$imputations[[3]] # Allow three-way interactions among categorical variables imp <- glemb(mydata, m = 20, noms = c(race, gender), cat.interact = 3, seed = 123) # Exclude a subject ID from the imputation model imp <- glemb(mydata, m = 20, noms = c(race, gender), idvars = "subject_id", seed = 123) # Use a saturated mean model (cell-specific intercepts; more flexible, # requires more data) imp <- glemb(mydata, m = 20, noms = c(race, gender), meanmodel = "saturated", seed = 123) ## End(Not run)
Print a glemb object
## S3 method for class 'glemb' print(x, digits = 3L, ...)## S3 method for class 'glemb' print(x, digits = 3L, ...)
x |
A |
digits |
Integer. Number of decimal places for numeric values.
Default is |
... |
Ignored. |
x, invisibly.
Prints a summary of the imputation model and the missingness in the first imputed dataset.
## S3 method for class 'glemb' summary(object, digits = 3L, ...)## S3 method for class 'glemb' summary(object, digits = 3L, ...)
object |
A |
digits |
Integer. Number of decimal places for numeric values.
Default is |
... |
Ignored. |
object, invisibly.