| Title: | Multiple Imputation Using the General Location Model with the EMB Algorithm |
| Version: | 0.1.4 |
| Description: | Provides multiple imputation for mixed continuous and categorical data using the General Location Model (Olkin and Tate (1961) <doi:10.1214/aoms/1177705052>; Little and Schluchter (1985) <doi:10.1093/biomet/72.3.497>) combined with the Expectation-Maximization with Bootstrapping (EMB) algorithm of Honaker, King and Blackwell (2011) <doi:10.18637/jss.v045.i07>. 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, ISBN:978-0-471-08705-2). |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| LazyData: | true |
| ByteCompile: | true |
| Imports: | mix |
| Suggests: | mice, mitml, testthat (≥ 3.0.0), knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Depends: | R (≥ 4.0.0) |
| URL: | https://github.com/pauldallison/glemb |
| BugReports: | https://github.com/pauldallison/glemb/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-05 00:15:34 UTC; allis |
| Author: | Paul Allison [aut, cre] |
| Maintainer: | Paul Allison <allison@statisticalhorizons.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-15 17:30:12 UTC |
Convert a glemb object to a mids object
Description
Converts a glemb object to the mids format used by the mice package,
enabling use of mice::pool() for results pooling.
Usage
as.mids.glemb(x, data, ...)
Arguments
x |
A |
data |
The original incomplete data frame that was passed to |
... |
Ignored. |
Details
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.
Value
A mids object.
See Also
Examples
if (requireNamespace("mice", quietly = TRUE)) {
imp <- glemb(nlsymiss, m = 5,
noms = c(race, pov, momwork, divorce, gender),
output = "list", seed = 1)
mids_obj <- as.mids.glemb(imp, data = nlsymiss)
fit <- with(mids_obj, lm(anti ~ self + pov + race + childage + divorce +
gender + momwork))
mice::pool(fit)
}
Multiple Imputation Using the General Location Model with the EMB Algorithm
Description
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.
Usage
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
)
Arguments
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, |
Details
Statistical model
The General Location Model (Olkin & Tate 1961; Little & Schluchter 1985) factorises the joint distribution of continuous variables y and categorical variables x as:
p(\mathbf{y}, \mathbf{x}) =
p(\mathbf{y} \mid \mathbf{x})\, p(\mathbf{x})
The categorical margin p(\mathbf{x}) is modelled with a log-linear
model restricted to at most cat.interact-way interactions among the
categorical variables. The continuous conditional
p(\mathbf{y} \mid \mathbf{x} = c) 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.
EMB algorithm
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
mtimes to producemcompleted datasets.
Sparsity
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.
Value
An object of class "glemb", which is a list with components:
imputationsA list of
mcompleted 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".
References
Olkin, I. & Tate, R.F. (1961). Multivariate correlation models with mixed discrete and continuous variables. Annals of Mathematical Statistics, 32, 448–465. doi:10.1214/aoms/1177705052
Little, R.J.A. & Schluchter, M.D. (1985). Maximum likelihood estimation for mixed continuous and categorical data with missing values. Biometrika, 72, 497–512. doi:10.1093/biomet/72.3.497
Honaker, J., King, G. & Blackwell, M. (2011). Amelia II: A program for missing data. Journal of Statistical Software, 45(7), 1–47. doi:10.18637/jss.v045.i07
Schafer, J.L. (1997). Analysis of Incomplete Multivariate Data. Chapman & Hall.
See Also
print.glemb(), summary.glemb(), as.mids.glemb()
Examples
# Impute the NLSY data, treating five variables as categorical
imp <- glemb(nlsymiss, m = 5, noms = c(race, pov, momwork, divorce, gender),
seed = 123)
# Fit a regression to each completed dataset and pool the results
if (requireNamespace("mice", quietly = TRUE)) {
fit <- with(imp, lm(anti ~ self + pov + race + childage + divorce +
gender + momwork))
summary(mice::pool(fit))
}
# Quoted names work too; output = "list" returns a glemb object
imp <- glemb(nlsymiss, m = 5,
noms = c("race", "pov", "momwork", "divorce", "gender"),
output = "list", seed = 123)
head(imp$imputations[[3]])
# Allow three-way interactions among categorical variables
imp <- glemb(nlsymiss, m = 5, noms = c(race, pov, momwork),
cat.interact = 3, output = "list", seed = 123)
# Use a saturated mean model (cell-specific intercepts; more flexible,
# requires more data)
imp <- glemb(nlsymiss, m = 5, noms = c(race, pov, momwork),
meanmodel = "saturated", output = "list", seed = 123)
Children's behavior data from the NLSY, with missing values
Description
A subsample of 581 children interviewed in 1990 as part of the National Longitudinal Survey of Youth (NLSY), used as a running example in Allison (2001). Five of the nine variables have missing values, and only 225 cases are complete. The data mix continuous and categorical variables, which makes them a natural application of the General Location Model.
Usage
nlsymiss
Format
A data frame with 581 rows and 9 variables:
- anti
Antisocial behavior score (0–6).
- self
Self-esteem score (9–24); 148 missing.
- pov
Family in poverty (1 = yes, 0 = no); 150 missing.
- childage
Child's age in years.
- divorce
Mother divorced (1 = yes, 0 = no).
- gender
Child's gender (1 = female, 0 = male).
- momage
Mother's age at the child's birth.
- momwork
Mother employed (1 = yes, 0 = no); 86 missing.
- race
Race/ethnicity: 1 = neither Black nor Hispanic, 2 = Black, 3 = Hispanic; 113 missing.
Source
U.S. Bureau of Labor Statistics, National Longitudinal Survey of Youth, Children data, 1990.
References
Allison, P.D. (2001). Missing Data. Sage Publications.
Examples
summary(nlsymiss)
colSums(is.na(nlsymiss))
Print a glemb object
Description
Print a glemb object
Usage
## S3 method for class 'glemb'
print(x, digits = 3L, ...)
Arguments
x |
A |
digits |
Integer. Number of decimal places for numeric values.
Default is |
... |
Ignored. |
Value
x, invisibly.
Examples
imp <- glemb(nlsymiss, m = 5, noms = c(race, pov, momwork, divorce, gender),
output = "list", seed = 1)
print(imp)
Summarise a glemb object
Description
Prints a summary of the imputation model and the missingness in the first imputed dataset.
Usage
## S3 method for class 'glemb'
summary(object, digits = 3L, ...)
Arguments
object |
A |
digits |
Integer. Number of decimal places for numeric values.
Default is |
... |
Ignored. |
Value
object, invisibly.
Examples
imp <- glemb(nlsymiss, m = 5, noms = c(race, pov, momwork, divorce, gender),
output = "list", seed = 1)
summary(imp)