Skip to content

DHARMa

0.5.0Package record

Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models

9packages dependsuggested by 20
319.1Kdownloads / year
71.0%test coverage
8/13flavors OK

Overview

About

"Uses a simulation-based approach to create readily interpretable scaled (quantile) residuals for fitted generalized linear (mixed) models. Currently supported are linear and generalized linear (mixed) models from 'lme4' (classes 'lmerMod', 'glmerMod'), 'glmmTMB', 'GLMMadaptive', 'spaMM', and 'brms' (simple models); phylogenetic linear models from 'phylolm' (classes 'phylolm' and 'phyloglm'); generalized additive models ('gam' from 'mgcv'); 'glm' (including 'negbin' from 'MASS', but excluding quasi-distributions) and 'lm' model classes. Moreover, externally created simulations, e.g. posterior predictive simulations from Bayesian software such as 'JAGS', 'STAN', or 'BUGS' can be processed as well. The resulting residuals are standardized to values between 0 and 1 and can be interpreted as intuitively as residuals from a linear regression. The package also provides a number of plot and test functions for typical model misspecification problems, such as over/underdispersion, zero-inflation, and residual spatial, temporal and phylogenetic autocorrelation."

Changes in 0.5.0

Major changes

  • For hierarchical models (GLMMs), we changed the default simulations from the supported model's default (mostly unconditional) to conditional simulations (for most of the supported models and packages). This represents a major change in the calculated scaled residuals and is implemented to ensure higher power in dispersion and other tests. We expect different results for calculated residuals using this or older DHARMa versions. For compatibility, you can use the argument simulateREs = "user-specified" to change back to the model's default (older DHARMa versions). See package vignette for more details.
  • In plotResiduals, we increased the threshold for the automatic change from quantile regression lines to the spline: from 2,000 to 10,000 data points. When it happens, a message is displayed to warn users. Also, when quantreg = F, the color of the spline was changed to black because there is no test associated with the line (as there is for quantile regression).
  • In plotResiduals, the argument form has a new functionality. Beyond the syntax data$predictor, it allows now to use the formula structure ~predictor, ~predictor1+predictor2, ~., ~predictor|group and ~predictor|group == "group_level" to plot the residuals against specific/all predictors and grouping variables/levels. This works for most of the supported model functions. It solves problems with NAs in datasets that were excluded by the model. #407 / #425
  • In testCategorical, recalculateResiduals, testQuantiles, testSpatialAutocorrelation and testTemporalAutocorrelation, additional predictors (catPred, group, sel, predictor, time, x,y- respectively) can now be specified as a formula (similar to plotResiduals). This handles rows with NAs that were excluded by the model automatically.
  • brms is now supported by DHARMa for simple models, i.e. models that could also be fit using glmmTMB (no multi-response, multinomial or structural equation models).

Bugfixes

  • Fixing error in runBenchmarks.
  • Fixing inconsistency in testQuantiles() #465. Including rankTransform() help function.

Minor changes

  • Using 95% confidence intervals for confidence bands in plots for testQuantiles(). Before, we were using standard errors (~ 68% CI).
  • Vectorize randomization of residuals to improve speed - PR#493 contributed by StaffanBetner.
Show all changes in 0.5.0Hide the rest of the changes in 0.5.0
  • Adding color legend to testSpatialAutocorrelation().
  • New function plotResidualsAll() to plot residuals against multiple predictors/all predictors of the model via plotResiduals().
  • New function getPredictorNames() extracts names of fixed and random effects (predictors) from a model.
  • testCategorical() now allows additional arguments to boxplot via ..., mainly to allow for appropriate x-axis labels when running plotResidualsAll().
  • Improved appearance of user-specified titles via "main" in plotResiduals().

From NEWS.md in the release

Install

Health

CRAN checks
5NOTE8OK
Check messages
NOTER code for possible problemsr-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-x86_64
Found calls to structure() using deprecated special names:
  DHARMa/inst/doc/DHARMa.R (.Label: 1, .Names: 1)
'.Label' should be changed to 'levels'.
'.Names' should be changed to 'names'.

CRAN check page ↗

Slowest check: 6.9 min · r-release-macos-x86_64
Status changes
  • NOTE8 OK, 5 NOTENow
  • NOTE10 OK, 3 NOTE2026-07-16
  • OK13 OK2026-06-09
  • ERROR12 OK, 1 ERROR2026-06-08
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 0.5.0
READMENoVignettesYes · 2 · dynamicNEWSYes · 100% structured · mentions 0.5.0Citation fileNoWebsiteYes
Help pages
57 (9 internal)includes a package overview page
Examples that run
94%30 run in a plain check · 2 never run
Exported functions with examples
68%
Documented parameters
96%
Return-value docs
15%
Help pages citing references
7%

Downloads

319.1K
CRAN downloads in the past year
Rank #613 · ~874/day · ~26.6K/mo
Daily download trend is not available in this view yet.
30.9K30 days
95.3K90 days
319.1K1 year
Compare downloads with other packages →
Also on1.4K r2u83 autocran4.6K conda_forge194 c2d4u

Repository

269Stars
31Forks
100Open issues
5Open PRs
47Releases
1,312Commits
33Commit identities
cranglmmresidualregressionregression-diagnostics
1,312 commits · Last activity 2026-10-02 · +1.9% stars, 30d
Responsiveness
How these are sampled
PRs merged (all time)
81%
Median days to close, 50 most recently updated closed issues
132
Median days to close, 50 most recently updated closed PRs
14

Stars over time

2025-10-19 · 2432026-10-12 · 269
PracticesBeta

5 development-tooling and community-health practices detected across 3 families in the upstream repository

Checks run against github.com/florianhartig/dharma on 2026-10-18.

Continuous integration (3)
GitHub ActionsR CMD check workflowTravis CI (config file)

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Docs source (1)

GitHub Pages site last deployed 2026-10-02

Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • GitHub Copilotfirst seen 2025-11-23
    Pull request: opened by its own account
How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
15 external dependencies (excludes base and recommended)

Installing DHARMa adds 86 packages (49 with compiled code, 88 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, data.table 5.7 MB.

Depends (1)
R >= 3.5.0
Imports (11)
statsgraphicsutilsgrDevicesMatrixparallelgaplmtestapeqgamlme4
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
9direct
3indirect
Imports 9
Suggested by 20
Show all 29 packagesHide all 29 packages
Depends, Imports or LinkingTo, most downloaded first
Suggests, most downloaded first

Datasets

People & History

People (4)
Author, Maintainer since 0.1.0 (2016)
Contributor · added in 0.3.3.0
Contributor · added in 0.5.0
Contributor · added in 0.4.7
Releases (29)

Pick two releases to compare their code metrics.

  • 0.5.0Latest
    record
    2026-06-01 · current release · diff ↗ ·
    added 3 exports
    getData, getPredictorNames, plotResidualsAll
  • R
    R 4.6.0 released · 2026-04-24
  • R
    R 4.5.0 released · 2025-04-11
  • 0.4.7
    record
    2024-10-18 · diff ↗ ·
    added 3 exports
    getFamily, getPearsonResiduals, testPhylogeneticAutocorrelation
  • R
    R 4.4.0 released · 2024-04-24
  • R
    R 4.3.0 released · 2023-04-21
  • 0.4.6
    record
    2022-09-08 · diff ↗ ·
    added 2 exports
    benchmarkRuntime, simulateLRT
  • R
    R 4.2.0 released · 2022-04-22
  • 0.4.5
    record
    2022-01-16 · diff ↗ ·
    removed 1 export
    getFixedEffects.MixMod
  • 0.4.4
    record
    2021-09-28 · diff ↗
  • 0.4.3
    record
    2021-07-07 · diff ↗
  • 0.4.2
    record
    2021-07-05 · diff ↗
  • R
    R 4.1.0 released · 2021-05-18
  • 0.4.1
    record
    2021-04-08 · diff ↗
  • 0.4.0
    record
    2021-03-28 · diff ↗
  • 0.3.4
    record
    2021-03-23 · diff ↗ ·
    added 3 exports
    getFixedEffects.MixMod, getResiduals, testCategorical
Show 24 earlier eventsHide 24 earlier events
  • 0.3.3.0
    record
    2020-09-08 · diff ↗
  • 0.3.2.0
    record
    2020-06-18 · diff ↗
  • 0.3.1
    record
    2020-05-12 · diff ↗ ·
    removed 1 export
    hasWeigths
    added 2 exports
    getQuantile, outliers
  • R
    R 4.0.0 released · 2020-04-24
  • 0.3.0
    record
    2020-04-20 · diff ↗ ·
    removed 2 exports
    getResponse, testModel
    added 6 exports
    getFitted, getFixedEffects, getObservedResponse, getRefit, hasWeigths, testQuantiles
  • 0.2.7
    record
    2020-02-06 · diff ↗
  • 0.2.6
    record
    2019-11-26 · diff ↗
  • 0.2.5
    record
    2019-11-18 · diff ↗ ·
    added 1 export
    transformQuantiles
  • R
    R 3.6.0 released · 2019-04-26
  • 0.2.4
    record
    2019-03-06 · diff ↗
  • 0.2.3
    record
    2019-02-12 · diff ↗
  • 0.2.2
    record
    2019-01-20 · diff ↗
  • 0.2.1
    record
    2019-01-17 · diff ↗ ·
    added 4 exports
    getResponse, getSimulations, testModel, testOutliers
  • 0.2.0
    record
    2018-06-05 · diff ↗ ·
    removed 3 exports
    benchmarkOverdispersion, benchmarkP, benchmarkUniformity
    added 6 exports
    getRandomState, recalculateResiduals, runBenchmarks, testDispersion, testGeneric, testResiduals
  • R
    R 3.5.0 released · 2018-04-23
  • 0.1.6
    record
    2018-03-18 · diff ↗ ·
    added 1 export
    plotQQunif
  • R
    R 3.4.0 released · 2017-04-21
  • 0.1.5
    record
    2017-03-11 · diff ↗
  • 0.1.4
    record
    2017-03-08 · diff ↗
  • 0.1.3
    record
    2016-12-12 · diff ↗
  • 0.1.2
    record
    2016-11-19 · diff ↗
  • 0.1.1
    record
    2016-11-16 · diff ↗ ·
    added 2 exports
    benchmarkP, createDHARMa
  • 0.1.0
    record
    2016-08-26
  • R
    R 3.3.0 released · 2016-05-03

Package metadata

First published
2016-08-26
Total releases
29 / 10 yrs
License
GPL (>= 3) OSI
Minimum R
≥ 3.5.0
Bundled data
3.5 KB / 1 file
Download size
3.7 MB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("DHARMa")
Hartig, F., Lohse, L., Werneke, C., & de Souza Leite, M. (2026). DHARMa: Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models (Version 0.5.0) [Computer software]. https://doi.org/10.32614/CRAN.package.DHARMa

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for DHARMa version 0.5.0 [Data set]. HJJB, LLC. Data release v2026-10-22. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy