suest for R

R-CMD-check

suest lets you compare predictions and marginal effects across regression models in R. It combines two or more separately fitted models into one object with a joint robust covariance matrix. That object works directly with marginaleffects, so you can calculate predictions and effects for each model and test whether they differ across models.

Combining models this way is seemingly unrelated estimation, developed by:

Weesie, Jeroen. 1999. “Seemingly Unrelated Estimation and the Cluster-Adjusted Sandwich Estimator.” Stata Technical Bulletin 52:34–47.

The package implements the framework for comparing predictions and marginal effects across models in:

Mize, Trenton D., Long Doan, and J. Scott Long. 2019. “A General Framework for Comparing Predictions and Marginal Effects Across Models.” Sociological Methodology 49(1):152–189. doi:10.1177/0081175019852763

The same framework is available in Stata through the mecompare command.

Installation

# install.packages("remotes")
remotes::install_github("tdmize/suest")

Basic usage

library(suest)
library(marginaleffects)

dat <- mtcars
dat$am <- factor(dat$am)

base <- glm(am ~ wt, family = binomial("logit"), data = dat)
adjusted <- glm(am ~ wt + hp, family = binomial("logit"), data = dat)
combined <- suest(base, adjusted, model_names = c("Base", "Adjusted"))

effects <- avg_comparisons(combined, variables = "wt", newdata = dat)
effects
hypotheses(effects, hypothesis = difference ~ revpairwise)

suest() accounts for the covariance between estimates from different models. This is essential when the models use the same or overlapping observations.

Supported models

suest works with linear, binary, ordinal, multinomial, count, censored, survival, and instrumental-variable models, as well as panel, multilevel, and survey models. Models can use the same, partially overlapping, or completely different samples. See the full list of supported models.

Learn more

Back to top