| Title: | Maximum Likelihood Estimation of Multiple Membership Mixed Models Used in Value-Added Modeling |
|---|---|
| Description: | An EM algorithm, Karl et al. (2013) <doi:10.1016/j.csda.2012.10.004>, estimates generalized, reduced generalized, variable, complete, and zero persistence models by maximum likelihood or restricted maximum likelihood (the default). These are multiple-membership linear mixed models with teachers modeled as "G-side" effects and students modeled with either "G-side" or "R-side" effects; see Mariano et al. (2010) <doi:10.3102/1076998609346967>. |
| Authors: | Andrew Karl [cre, aut] (ORCID: <https://orcid.org/0000-0002-5933-8706>), Yan Yang [aut], Sharon Lohr [aut] |
| Maintainer: | Andrew Karl <[email protected]> |
| License: | GPL-2 |
| Version: | 3.3-0 |
| Built: | 2026-09-18 19:48:33 UTC |
| Source: | https://github.com/cran/GPvam |
An EM algorithm fits multiple-membership linear mixed models used in
educational value-added assessment. Teachers are modeled with random
effects; dependence among a student's observations is modeled through
either the residual covariance or a random student effect.
Restricted maximum likelihood (REML) is used by default; set
REML = FALSE in GPvam for maximum likelihood (ML).
Use GPvam to fit generalized, reduced generalized, variable,
complete, or zero persistence models. summary.GPvam summarizes
a fitted model and plot.GPvam draws diagnostic plots.
bias.test.custom provides a permutation diagnostic for bias
induced by dependence between random effects and their model matrix.
The package includes simulated example data in vam_data and
historical runtime and memory measurements in GPvam.benchmark.
Andrew Karl [email protected], Yan Yang and Sharon Lohr.
Karl, A. T. (2026). Motivating REML via Prediction-Error Covariances in EM Updates for Linear Mixed Models. arXiv:2602.09247v1. https://arxiv.org/abs/2602.09247.
Karl, A., Yang, Y. and Lohr, S. (2013). Efficient Maximum Likelihood Estimation of Multiple Membership Linear Mixed Models, with an Application to Educational Value-Added Assessments. Computational Statistics & Data Analysis 59, 13–27. doi:10.1016/j.csda.2012.10.004.
Karl, A., Yang, Y. and Lohr, S. (2014). Computation of Maximum Likelihood Estimates for Multiresponse Generalized Linear Mixed Models with Non-nested, Correlated Random Effects. Computational Statistics & Data Analysis 73, 146–162.
Karl, A., Yang, Y. and Lohr, S. (2013). A Correlated Random Effects Model for Nonignorable Missing Data in Value-Added Assessment of Teacher Effects. Journal of Educational and Behavioral Statistics 38, 577–603. doi:10.3102/1076998613494819.
Karl, A. and Zimmerman, D. (2021). A diagnostic for bias in linear mixed model estimators induced by dependence between the random effects and the corresponding model matrix. Journal of Statistical Planning and Inference 211, 107–118. doi:10.1016/j.jspi.2020.06.004.
Lockwood, J., McCaffrey, D., Mariano, L. and Setodji, C. (2007). Bayesian Methods for Scalable Multivariate Value-Added Assessment. Journal of Educational and Behavioral Statistics 32, 125–150.
Mariano, L., McCaffrey, D. and Lockwood, J. (2010). A Model for Teacher Effects From Longitudinal Data Without Assuming Vertical Scaling. Journal of Educational and Behavioral Statistics 35, 253–279. doi:10.3102/1076998609346967.
McCaffrey, D. and Lockwood, J. (2011). Missing Data in Value-Added Modeling of Teacher Effects. Annals of Applied Statistics 5, 773–797.
Use fitted random effects to diagnose potential bias in fixed-effect estimates or their contrasts, following Karl and Zimmerman (2021). The diagnostic addresses dependence between random effects and the corresponding model matrix.
bias.test.custom( result, k_vectors = NULL, n_perms = 1e+05, plot = TRUE, verbose = TRUE )bias.test.custom( result, k_vectors = NULL, n_perms = 1e+05, plot = TRUE, verbose = TRUE )
result |
A fitted |
k_vectors |
A numeric contrast vector, or a list of such vectors.
Each vector must have one finite coefficient per column of |
n_perms |
Positive integer number of random permutations for each
contrast. The default is |
plot |
Logical; display the permutation histograms and their combined
plot. Histogram objects are returned even when |
verbose |
Logical; print progress and the results table. |
For a contrast , the observed diagnostic is , with
Here and are the fixed- and random-effects design matrices,
is the fitted marginal covariance, and is the vector
of predicted random effects.
Teacher effects are permuted among teachers from the same originating year. For generalized and reduced generalized persistence models, each teacher's whole vector of current and future effects moves together, preserving the within-teacher covariance structure. Random student intercepts in G-side models are permuted separately among students. This block permutation specializes the diagnostic to GPvam's covariance structure; it does not implement the rank-based sampler in Karl and Zimmerman (2021).
The reported two-sided Monte Carlo p-value is
, where counts permutations whose
absolute diagnostic is at least as large as the observed value. Including
the observed arrangement avoids zero p-values from a finite random sample
of permutations (Phipson and Smyth, 2010). Because covariance parameters
and random effects are estimated, these are approximate fitted-model
diagnostics, not exact finite-sample tests of fixed-effect bias.
Permutations use R's current random-number generator. Call
set.seed() before the diagnostic to reproduce the results.
A list with:
permutation_results |
A data frame with columns |
plot_list |
A list of |
Karl, A. and Zimmerman, D. (2021). A diagnostic for bias in linear mixed model estimators induced by dependence between the random effects and the corresponding model matrix. Journal of Statistical Planning and Inference 211, 107–118. doi:10.1016/j.jspi.2020.06.004.
Phipson, B. and Smyth, G. K. (2010). Permutation P-values Should Never Be Zero: Calculating Exact P-values When Permutations Are Randomly Drawn. Statistical Applications in Genetics and Molecular Biology 9(1), Article 39. doi:10.2202/1544-6115.1585.
data(vam_data) result <- GPvam(vam_data, persistence = "CP", fixed_effects = ~ as.factor(year) + cont_var + 0, verbose = FALSE) set.seed(2026) bias <- bias.test.custom(result, k_vectors = c(0, 0, 0, 1), n_perms = 999, plot = FALSE, verbose = FALSE) bias$permutation_resultsdata(vam_data) result <- GPvam(vam_data, persistence = "CP", fixed_effects = ~ as.factor(year) + cont_var + 0, verbose = FALSE) set.seed(2026) bias <- bias.test.custom(result, k_vectors = c(0, 0, 0, 1), n_perms = 999, plot = FALSE, verbose = FALSE) bias$permutation_results
Fit a multiple-membership linear mixed model by an EM algorithm. Teacher effects may persist into future years, and dependence among a student's observations is represented by a residual covariance matrix or a random student effect. See Karl, Yang and Lohr (2013) and Mariano et al. (2010).
GPvam( vam_data, fixed_effects = formula(~as.factor(year) + 0), student.side = "R", persistence = "GP", max.iter.EM = 1000, tol1 = 1e-07, hessian = FALSE, hes.method = "simple", REML = TRUE, verbose = TRUE )GPvam( vam_data, fixed_effects = formula(~as.factor(year) + 0), student.side = "R", persistence = "GP", max.iter.EM = 1000, tol1 = 1e-07, hessian = FALSE, hes.method = "simple", REML = TRUE, verbose = TRUE )
vam_data |
A data frame containing |
fixed_effects |
A one-sided formula specifying fixed effects. The
default estimates a separate mean for each year, or an intercept if there
is only one year. Use factors for
categorical covariates; for example,
|
student.side |
Character string, either |
persistence |
Character string selecting |
max.iter.EM |
Positive integer giving the maximum number of EM
iterations. A fit that reaches this limit without convergence is returned
with a warning and |
tol1 |
Positive finite convergence tolerance for the relative change
in log likelihood. The default is |
hessian |
Logical; calculate the observed information for covariance
parameters and, for |
hes.method |
Numerical differentiation method for the information
matrix: |
REML |
Logical; use restricted maximum likelihood (the default) rather than maximum likelihood. Supported for every available persistence/student-side combination. |
verbose |
Logical; print model information and iteration progress. |
The model is fitted by an EM algorithm based on Karl, Yang and Lohr
(2013). Covariance updates use conditional random-effect moments for ML
and prediction-error covariance adjustments for REML; see Karl (2026).
With incomplete observation patterns, the unstructured residual covariance
update uses a Cholesky parameterization to retain positive definiteness.
Setting hessian = TRUE adds numerical differentiation after fitting
and can substantially increase runtime. Historical timings are available
in GPvam.benchmark.
Fixed-effect standard errors and teacher prediction-error standard deviations use the inverse mixed-model coefficient matrix with estimated covariance parameters treated as known. They do not include an additional adjustment for uncertainty in those covariance estimates.
An object of class GPvam, a list that includes:
loglik |
Log likelihood (restricted log likelihood for REML) at the returned fit. Meeting the relative-change convergence criterion does not guarantee a global maximum. |
converged |
Whether the convergence criterion was met. |
iter, loglik_history
|
Number of evaluated iterations and the corresponding sequence of log likelihoods. |
teach.effects |
Data frame containing teacher identifiers, originating
and effect years, predicted effects ( |
parameters |
Matrix of fixed-effect, covariance, and applicable
persistence estimates with their standard errors. Covariance and
persistence standard errors are |
Hessian |
Observed information matrix for covariance and persistence
parameters when requested, otherwise |
R_i |
Within-student residual covariance for R-side models;
|
teach.cov |
List of teacher covariance blocks, one per originating year. |
stu.cov |
Student random-effect variance for a G-side model;
|
mresid, cresid, sresid
|
Marginal residuals, conditional residuals, and conditional residuals scaled using the residual precision matrix. |
y, yhat, yhat.m, yhat.s
|
Observed responses, conditional fitted values, marginal fitted values, and scaled conditional fitted values, in the internal fitting order. |
X, Z, G, R.inv, vinv
|
Fixed- and random-effects design matrices, random-effects covariance, residual precision, and marginal precision. |
ybetas, eta.hat
|
Unrounded fixed-effect estimates and random-effect predictions. |
num.obs, num.student, num.year, num.teach
|
Observation, student, year, and per-year teacher counts. |
persistence, student.side, REML
|
The fitted model and estimation options. |
key |
Mapping between original year values and internal year indices. |
observation |
Input-row indices in the internal fitting order. |
call, fixed_effects
|
Original model call and fixed-effects formula. |
Use the standard GPvam-methods to extract full-precision
fixed-effect estimates and covariances, fitted values, residuals, likelihood,
and observation count. The fitted-value and residual methods return
observations in input order with missing responses omitted.
The generalized persistence model ("GP") assigns each teacher
correlated current-year and future-year effects. The reduced model
("rGP") combines a teacher's future-year effects into one shared
effect. The variable persistence model ("VP") makes a teacher's
future-year effects multiples of the current-year effect and estimates
those multipliers. Complete ("CP") and zero ("ZP") persistence
fix the multipliers at one and zero, respectively.
With student.side = "R", an unstructured covariance matrix models
within-student dependence. With student.side = "G", a random student
intercept represents that dependence and the remaining errors are
independent, with a separate variance for each year. The latter
formulation assumes that scores across years use a common scale and can
have substantial memory requirements for large numbers of random effects.
A missing score is omitted from the response used for fitting. A known
teacher assignment on that row is retained in the student's teaching
history and can contribute persistent effects to later observed scores.
A missing teacher identifier represents an unknown assignment, not a
teacher named "NA"; no teacher effect is attached to that assignment.
Each teacher-year is a separate unit. If the same teacher identifier
appears in different years, the corresponding effects are modeled
independently. Internally, a year suffix is added to each known teacher
identifier, and the original year labels are retained in the output.
Before evaluating fixed_effects, years are recoded to consecutive
numeric indices in increasing order. Thus ~ year specifies a linear
trend across those indices. To use the original numerical spacing, copy
the original years into a separate covariate and use that covariate in
the formula.
The fixed-effects design must have full column rank. Use
~ as.factor(year) * cont_var + 0 to include year-specific slopes;
see formula for formula syntax.
Andrew Karl [email protected], Yan Yang and Sharon Lohr.
Karl, A. T. (2026). Motivating REML via Prediction-Error Covariances in EM Updates for Linear Mixed Models. arXiv:2602.09247v1. https://arxiv.org/abs/2602.09247.
Karl, A., Yang, Y. and Lohr, S. (2013). Efficient Maximum Likelihood Estimation of Multiple Membership Linear Mixed Models, with an Application to Educational Value-Added Assessments. Computational Statistics & Data Analysis 59, 13–27. doi:10.1016/j.csda.2012.10.004.
Karl, A., Yang, Y. and Lohr, S. (2014). Computation of Maximum Likelihood Estimates for Multiresponse Generalized Linear Mixed Models with Non-nested, Correlated Random Effects. Computational Statistics & Data Analysis 73, 146–162.
Karl, A., Yang, Y. and Lohr, S. (2013). A Correlated Random Effects Model for Nonignorable Missing Data in Value-Added Assessment of Teacher Effects. Journal of Educational and Behavioral Statistics 38, 577–603. doi:10.3102/1076998613494819.
Karl, A. and Zimmerman, D. (2021). A diagnostic for bias in linear mixed model estimators induced by dependence between the random effects and the corresponding model matrix. Journal of Statistical Planning and Inference 211, 107–118. doi:10.1016/j.jspi.2020.06.004.
Lockwood, J., McCaffrey, D., Mariano, L. and Setodji, C. (2007). Bayesian Methods for Scalable Multivariate Value-Added Assessment. Journal of Educational and Behavioral Statistics 32, 125–150.
Mariano, L., McCaffrey, D. and Lockwood, J. (2010). A Model for Teacher Effects From Longitudinal Data Without Assuming Vertical Scaling. Journal of Educational and Behavioral Statistics 35, 253–279. doi:10.3102/1076998609346967.
McCaffrey, D. and Lockwood, J. (2011). Missing Data in Value-Added Modeling of Teacher Effects. Annals of Applied Statistics 5, 773–797.
plot.GPvam, summary.GPvam,
bias.test.custom, vam_data
data(vam_data) result <- GPvam(vam_data, persistence = "CP", fixed_effects = ~ as.factor(year) + cont_var + 0, verbose = FALSE) summary(result) plot(result, ask = FALSE)data(vam_data) result <- GPvam(vam_data, persistence = "CP", fixed_effects = ~ as.factor(year) + cont_var + 0, verbose = FALSE) summary(result) plot(result, ask = FALSE)
Standard model methods expose the unrounded estimates used by the fitting
algorithm. The displayed parameters table is rounded for presentation.
## S3 method for class 'GPvam' coef(object, ...) ## S3 method for class 'GPvam' vcov(object, ...) ## S3 method for class 'GPvam' fitted(object, type = c("conditional", "marginal"), ...) ## S3 method for class 'GPvam' residuals(object, type = c("conditional", "marginal", "scaled"), ...) ## S3 method for class 'GPvam' nobs(object, ...) ## S3 method for class 'GPvam' logLik(object, ...)## S3 method for class 'GPvam' coef(object, ...) ## S3 method for class 'GPvam' vcov(object, ...) ## S3 method for class 'GPvam' fitted(object, type = c("conditional", "marginal"), ...) ## S3 method for class 'GPvam' residuals(object, type = c("conditional", "marginal", "scaled"), ...) ## S3 method for class 'GPvam' nobs(object, ...) ## S3 method for class 'GPvam' logLik(object, ...)
object |
A fitted |
... |
Further arguments, currently unused. |
type |
For |
logLik returns the likelihood criterion actually fitted (ML or REML).
It does not refit or convert between likelihood types. The parameter-count
convention agrees with common R mixed-model packages. Compare REML likelihoods
or information criteria only for models with the same fixed-effect design and
the same observations; ML and REML criteria are not directly comparable.
These methods apply to objects fitted by GPvam 3.3-0 or later, which retain full-precision matrices and an input-row map for all model settings.
coef returns a named fixed-effect coefficient vector;
vcov returns its estimated covariance matrix. fitted and
residuals return named numeric vectors in the order of the input rows
with observed responses. Rows with missing responses are omitted.
nobs returns the number of observed responses. logLik returns
an object of class logLik, with degrees of freedom equal to the
number of fixed-effect and covariance/persistence parameters.
data(vam_data) fit <- GPvam(vam_data, persistence = "CP", verbose = FALSE) coef(fit) vcov(fit) head(fitted(fit)) head(residuals(fit, type = "marginal")) logLik(fit) nobs(fit)data(vam_data) fit <- GPvam(vam_data, persistence = "CP", verbose = FALSE) coef(fit) vcov(fit) head(fitted(fit)) head(residuals(fit, type = "marginal")) logLik(fit) nobs(fit)
Runtime and peak memory measurements for different persistence models and simulated data sets. The data sets vary in their numbers of years, teachers per year, and students per teacher. These are historical measurements, not predictions for a current computer or package version.
data(GPvam.benchmark)data(GPvam.benchmark)
A data frame with 160 rows and nine variables:
Persistence model and, where indicated, student side.
Number of years.
Number of students per teacher.
Number of teachers per year.
Total student-year records, equal to
Years * Students.per.Teacher * Teachers.per.Year; the original
column name is retained.
Total number of teacher-year effects.
Number of random effects.
Peak memory usage in megabytes.
Runtime in minutes.
All benchmarks used hessian = TRUE. Numerical Hessian
calculation accounted for 20% to 75% of the recorded runtimes.
Use hessian = FALSE when standard errors of covariance and persistence
parameters are not required. The G-side student model can have large memory
requirements as the numbers of students and teachers increase.
data(GPvam.benchmark) head(GPvam.benchmark)data(GPvam.benchmark) head(GPvam.benchmark)
Draw caterpillar plots of teacher effects with normal-approximation intervals, normal Q-Q plots of conditional residuals, and residuals against fitted values.
## S3 method for class 'GPvam' plot(x, ..., alpha = 0.1, ask = interactive())## S3 method for class 'GPvam' plot(x, ..., alpha = 0.1, ask = interactive())
x |
An object of class |
... |
Additional graphical arguments passed to the plotting functions. |
alpha |
Significance level for the caterpillar intervals, a finite
number strictly between zero and one. The default |
ask |
Logical; ask before advancing to the next plot. Defaults to
|
Caterpillar intervals use the teacher prediction-error standard deviations
returned by GPvam, treating estimated covariance parameters as
known. They do not include an adjustment for estimation of the covariance
parameters. Separate caterpillar plots are drawn for each available
originating-year/effect-year pair using the original year labels.
Earlier versions of GPvam used caterpillar code adapted from
plotCI in package gplots. Its original version was posted
to R-help by Bill Venables
on September 20, 1997; an enhanced version was posted by Ben Bolker on
April 16, 2001. Gregory R. Warnes modified and extended that version, and
changes suggested by Martin Maechler were integrated on July 29, 2004.
The input object x, invisibly. Plots are drawn on the active
graphics device.
Andrew Karl [email protected], Yan Yang and Sharon Lohr. Caterpillar plotting contributors are listed in ‘Details’.
data(vam_data) result <- GPvam(vam_data, persistence = "CP", verbose = FALSE) plot(result, alpha = 0.05, ask = FALSE)data(vam_data) result <- GPvam(vam_data, persistence = "CP", verbose = FALSE) plot(result, alpha = 0.05, ask = FALSE)
Print the fitting iteration count, likelihood, estimated parameters, and teacher effects. The summary print method also displays covariance matrices, information criteria, and residual summaries.
## S3 method for class 'GPvam' print(x, ...) ## S3 method for class 'summary.GPvam' print(x, ...)## S3 method for class 'GPvam' print(x, ...) ## S3 method for class 'summary.GPvam' print(x, ...)
x |
An object of class |
... |
Additional arguments; currently unused. |
Teacher effects and covariance matrices are formatted using six significant digits for display. The fitted object retains their full numerical precision, and correlations use the unrounded covariances.
The input object x, invisibly.
Add information criteria to a fitted model for display by its summary print method.
## S3 method for class 'GPvam' summary(object, ...)## S3 method for class 'GPvam' summary(object, ...)
object |
An object of class |
... |
Additional arguments; currently unused. |
AIC is , where is the reported likelihood and
counts estimated fixed effects and covariance/persistence
parameters. Restricted-likelihood criteria should only compare models
with the same fixed-effects design and response data. Do not compare
ML and REML criteria directly.
For ML fits, AICc is the conventional adjustment
, using the number of observed scores
for . It is a heuristic for these correlated-data models, not a
model-specific finite-sample correction. It is returned as NA for
REML fits or when .
An object of class summary.GPvam, containing the fitted
object's components plus AIC and AICc.
Andrew Karl [email protected], Yan Yang and Sharon Lohr.
data(vam_data) result <- GPvam(vam_data, persistence = "CP", verbose = FALSE) summary(result)data(vam_data) result <- GPvam(vam_data, persistence = "CP", verbose = FALSE) summary(result)
A data set simulated from a variable persistence model, illustrating a model with perfectly correlated current and future effects for each teacher.
data(vam_data)data(vam_data)
A data frame with 3,750 observations on 1,250 students over three years, with 50 teachers in each year, and five variables:
Numeric student identifier.
Numeric teacher identifier, interpreted within year.
Numeric observation year, from 1 to 3.
Numeric student score.
Numeric continuous covariate.
Scores combine a student effect, current and persistent teacher effects, the continuous covariate, and independent errors. The persistence multiplier is 0.4. The student, teacher, and residual standard deviations are each 5; the covariate standard deviation is 4 and its coefficient is 1.
The original simulation used the following code and R's pre-3.6.0
"Rounding" sampler. On R 3.6.0 or later, first select
RNGkind(sample.kind = "Rounding") to reproduce the supplied data,
and restore your preferred RNG settings afterward. With that sampler,
the code reproduces the stored data exactly.
set.seed(0) years <- 3 teachers <- 50 students <- 25 alpha <- .4 eta.stu <- rnorm(students * teachers, 0, 5) z1 <- rep(1:teachers, each = students) z2 <- sample(rep(1:teachers, each = students)) z3 <- sample(rep(1:teachers, each = students)) cont_var1 <- rnorm(students * teachers, 0, 4) cont_var2 <- rnorm(students * teachers, 0, 4) cont_var3 <- rnorm(students * teachers, 0, 4) gam1 <- rnorm(teachers, 0, 5) gam2 <- rnorm(teachers, 0, 5) gam3 <- rnorm(teachers, 0, 5) eps1 <- rnorm(students * teachers, 0, 5) eps2 <- rnorm(students * teachers, 0, 5) eps3 <- rnorm(students * teachers, 0, 5) y1 <- eta.stu + gam1[z1] + cont_var1 + eps1 y2 <- eta.stu + gam1[z1] * alpha + gam2[z2] + cont_var2 + eps2 y3 <- eta.stu + gam1[z1] * alpha + gam2[z2] * alpha + gam3[z3] + cont_var3 + eps3 student <- 1:(students * teachers) teacher <- c(z1, z2, z3) cont_var <- c(cont_var1, cont_var2, cont_var3) year <- rep(1:3, each = students * teachers) y <- c(y1, y2, y3) vam_data <- as.data.frame(cbind(student, teacher, year, y, cont_var))
data(vam_data) head(vam_data)data(vam_data) head(vam_data)