Package: merTools 1.0.0

merTools: Tools for Analyzing Mixed Effect Regression Models

Provides methods for extracting results from mixed-effect model objects fit with the 'lme4' package. Allows construction of prediction intervals efficiently from large scale linear and generalized linear mixed-effects models. This method draws from the simulation framework used in the Gelman and Hill (2007) textbook: Data Analysis Using Regression and Multilevel/Hierarchical Models.

Authors:Jared E. Knowles [aut, cre], Carl Frederick [aut], Alex Whitworth [ctb]

merTools_1.0.0.tar.gz
merTools_1.0.0.zip(r-4.7)merTools_1.0.0.zip(r-4.6)merTools_1.0.0.zip(r-4.5)
merTools_1.0.0.tgz(r-4.6-any)merTools_1.0.0.tgz(r-4.5-any)
merTools_1.0.0.tar.gz(r-4.7-any)merTools_1.0.0.tar.gz(r-4.6-any)
merTools_1.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
merTools/json (API)

# Install 'merTools' in R:
install.packages('merTools', repos = c('https://jknowles.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/jknowles/mertools/issues

Pkgdown/docs site:https://jknowles.github.io

Datasets:
  • hsb - A subset of data from the 1982 High School and Beyond survey used as examples for HLM software

On CRAN:

Conda:

12.61 score 102 stars 2 packages 915 scripts 8.1k downloads 18 mentions 32 exports 60 dependencies

Last updated from:e6060e0656. Checks:9 OK. Indexed: yes.
A new build is currently in progress.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK254
source / vignettesOK247
linux-release-x86_64OK269
macos-release-arm64OK156
macos-oldrel-arm64OK147
windows-develOK229
windows-releaseOK210
windows-oldrelOK205
wasm-releaseOK151

Exports:averageObsbglmerModListblmerModListdrawexpectedRankfastdispFEsimfindFormFunsglmerModListICClmerModListmodelFixedEffmodelInfomodelRandEffStatsplotFEsimplotREimpactplotREsimpredictIntervalrandomObsREcorrExtractREextractREimpactREmarginsREquantileREsdExtractREsimRMSE.merModshinyMersubBootsuperFactorthetaExtractwiggle

Dependencies:abindarmbackportsblmebootbroombroom.mixedclicodacodetoolscpp11digestdplyrfarverforcatsforeachfurrrfuturegenericsggplot2globalsgluegtableisobanditeratorslabelinglatticelifecyclelistenvlme4magrittrMASSMatrixminqamvtnormnlmenloptrparallellypillarpkgconfigpurrrR6rbibutilsRColorBrewerRcppRcppEigenRdpackreformulasrlangS7scalesstringistringrtibbletidyrtidyselectutf8vctrsviridisLitewithr

An Introduction to merTools
Introduction | Illustrating Model Effects | Random Effects | Substantive Effects | Uncertainty

Last update: 2026-05-30
Started: 2015-05-27

Exploring Contextual Effects with merTools
Contextual effects | The data | A contextual-effects model | Predictions that separate the two effects | How much do schools matter across the rank distribution? | References

Last update: 2026-05-30
Started: 2026-05-29

Analyzing Imputed Data with Multilevel Models and merTools
Introduction | Missing Data and its Discontents | Fitting and Summarizing a Model List | Output of a Model List | Specific Model Information Summaries | Diagnostics of List Components | Model List Generics | Cautions and Notes

Last update: 2026-05-30
Started: 2017-07-10

Using merTools to Marginalize Over Random Effect Levels
Marginalizing Random Effects | Summarizing | Plotting

Last update: 2026-05-30
Started: 2019-05-11

Prediction Intervals from merMod Objects
Introduction | Conceptual description | Comparison to existing methods | Step 1: Estimating the model and using predictInterval() | Step 1a: Adjusting for correlation between fixed and random effects | Step 2: Comparison with arm::sim() | Step 3: Comparison with lme4::bootMer() | Step 3a: lme4::bootMer() method 1 | Step 3b: lme4::bootMer() method 2 | Step 3c: lme4::bootMer() method 3 | Step 3d: Comparison to rstanarm | Computation time | Simulation

Last update: 2026-05-30
Started: 2015-05-21

Validating predictInterval() against brms
Why compare to brms? | A random-slopes model | Point estimates are essentially identical | The prediction intervals agree | And they are equally well calibrated | At a fraction of the cost | What about an entirely new group? | A generalized linear mixed model | Takeaways

Last update: 2026-05-30
Started: 2026-05-30

Readme and manuals

Help Manual

Help pageTopics
Find the average observation for a merMod objectaverageObs
Collapse a dataframe to a single average rowcollapseFrame
Draw a single observation out of an object matching some criteriadraw draw.merMod
Calculate the expected rank of random coefficients that account for uncertainty.expectedRank
Find link function familyfamlink
fastdisp: faster display of model summariesfastdisp fastdisp.merMod fastdisp.merModList
Simulate fixed effects from merMod 'FEsim' simulates fixed effects from merMod object posterior distributionsFEsim
Extract all warning msgs from a merMod objectfetch.merMod.msgs
'findFormFuns' used by averageObs to calculate proper averagesfindFormFuns
Extract fixed-effects estimates for a merModListfixef.merModList
Identify if a merMod has weightshasWeights
A subset of data from the 1982 High School and Beyond survey used as examples for HLM softwarehsb
Calculate the intraclass correlation using mixed effect modelsICC
Apply a multilevel model to a list of data framesbglmerModList blmerModList glmerModList lmerModList
merModList S3 ClassmerModList merModList-class
Extract averaged fixed effect parameters across a list of merMod objectsmodelFixedEff
Extract model information from a merModmodelInfo
Extract data.frame of random effect statistics from merMod ListmodelRandEffStats
Extract all warning msgs from a merMod objectplot_sim_error_chks
Plot the results of a simulation of the fixed effectsplotFEsim
Plot the impact of grouping-factor levels on predictionsplotREimpact
Plot the results of a simulation of the random effectsplotREsim
Predict from merMod objects with a prediction intervalpredictInterval
Summarize a merMod listprint.merModList
Print the summary of a merMod listprint.summary.merModList
Select a random observation from model datarandomObs
Extract random-effects estimates for a merModListranef.merModList
Extract the correlations between the slopes and the intercepts from a modelREcorrExtract
Extracts random effectsREextract
Calculate the weighted mean of fitted values for various levels of random effect terms.REimpact
Calculate the predicted value for each observation across the distribution of the random effect terms.REmargins
Identify group level associated with RE quantileREquantile
Extract the standard deviation of the random effects from a merMod objectREsdExtract
Simulate random effects from merMod 'REsim' simulates random effects from merMod object posterior distributionsREsim
Estimate the Root Mean Squared Error (RMSE) for a lmerModRMSE.merMod
Clean up variable names in data framessanitizeNames
Set up parallel environmentsetup_parallel
Launch a shiny app to explore your merMod interactivelyshinyMer
Randomly reorder a dataframeshuffle
Simulate random‑effect contributions for all grouping factorssimulate_random_effects
Remove attributes from a data.framestripAttributes
Bootstrap a subset of an lme4 modelsubBoot
Subset a data.frame using a list of conditionssubsetList
Print the results of a merMod listsummary.merModList
Create a factor with unobserved levelssuperFactor
Extract theta parameters from a merMod modelthetaExtract
Extract the variances and correlations for random effects from a merMod listVarCorr.merModList
Assign an observation to different valueswiggle