Diagnostics for HierArchical Regression Models
What DHARMa supports for each regression package, and the checks behind it. Each package folder has a README.md with the support and its limits, and a script (checks.R) whose sections back the statements in the README (some statements cite a GitHub issue instead). The scripts stop with an error if a statement no longer holds, so they can be re-run after changes to DHARMa or to the packages.
The vignette (section “Supported packages and frameworks”) and the package tests (testModelTypes.R, testCompatibility.R) remain the user-facing documentation and the automated tests; these pages give the details and the evidence (see #446).
| Package | Model classes | Support | Main limits |
|---|---|---|---|
| stats, MASS | lm, glm, negbin |
full | no quasi families |
| lme4 | lmerMod, glmerMod, lmerModLmerTest; gamm4 via $mer |
full | na.exclude fails (#88, #134) |
| glmmTMB | glmmTMB |
full | no conditioning on selected REs; conditional simulations fall back to unconditional for exp() |
| mgcv | gam, bam |
full (one linear predictor), partial (several, #600) | only conditional simulations; extended families need mgcViz; several linear predictors (#600); multinom, gamm()$gam and gamm4()$gam not supported (#418, #612) |
| spaMM | HLfit |
full | no k/n binomial via weights |
| GLMMadaptive | MixMod |
partial | residuals sorted by the grouping factor; vector predictors must be in this order (#609); beta-binomial with more than one trial requires GLMMadaptive >= 0.9-9 (#565); no Pearson residuals |
| phylolm | phylolm, phyloglm |
partial | residuals in tree tip order; vector predictors must be in this order (#609); poisson_GEE and models fitted in functions fail (#478); no Pearson residuals |
| brms | brmsfit |
partial (univariate models) | weights() ignored (#7); unsupported model types with unclear errors (#612) |
| phyr | not checked | #235 | |
| gamlss, VGAM | not supported | #319, #322 | |
| sjSDM | not supported | ||
| INLA | not supported | no simulate() method; workaround: posterior samples with inla.posterior.sample(), response simulated by hand, read in with createDHARMa() (#341, not checked) |
|
| censReg, VAST, gjam, rstanarm | not checked | #223, #170, #164, #58 |
Problems that affect several packages:
ar1() with one observation per time step or spatial fields with one observation per location (strongly for Gaussian, less for Poisson models); the same mechanism applies to observation-level REs (not checked) (#527).rotation = "estimated" is strongly anti-conservative unless n is much larger than the number of observations (or groups, after recalculateResiduals(group = )); with 200 observations, the rejection rate of the uniformity test was 1.00 for the default n = 250 and 0.02 for n = 1000 (#489).na.action = na.exclude stops or gives unusable results (fitted values padded with NA) for all classes checked in #88 (lm, glm, glm.nb, lmer, glmer, glmmTMB, gam).From the repository root, with the packages of the respective folder installed:
source("Code/DHARMaPackageSupport/lme4/checks.R")
Each script sources supportChecks.R, which loads the current DHARMa (devtools::load_all("DHARMa")) and contains the shared check functions (checkInterface(), refitReproduces(), simulationVariance(), inDataOrder(), …). The scripts run on one core in 5 seconds (stats) to about 9 minutes (glmmTMB).
checks.R are RStudio sections (# Title ----), and README statements cite them as “checks.R, Title”. Statements already covered by the package tests cite the test instead of repeating it.stopifnot() for its statements. Known bugs are asserted as they currently behave (with the issue number, if any), so the script stops when they are fixed.archive/ subfolders (and in archive/ for files that were not package-specific).