Learn R Programming

⚠️There's a newer version (0.4.7) of this package.Take me there.

DHARMa - Residual Diagnostics for HierARchical Models

The DHARMa package creates readily interpretable residuals for generalized linear (mixed) models that are standardized to values between 0 and 1. This is achieved by a simulation-based approach, similar to the Bayesian p-value or the parametric bootstrap: 1) simulate new data from the fitted model 2) from this simulated data, calculate the cummulative density function 3) residual is the value of the empirical density function at the value of the observed data.

The package includes various functions that deal with issues such as

  • Misfit
  • Overdispersion
  • Zero-inflation
  • Residual temporal autocorrelation
  • Residual spatial autocorrelation

To get more information, install the package and run

library(DHARMa)
?DHARMa
vignette("DHARMa", package="DHARMa")

Acknowledgements

A question by Catalina Gutiérrez Chacón provided me with the motivation write the first version of DHARMa. Thanks to Jochen Fründ, Tomer J. Czaczkes, Luis Cayuela Delgado and Alexandre Courtiol for useful suggestions to improve the software.

Copy Link

Version

Install

install.packages('DHARMa')

Monthly Downloads

15,698

Version

0.2.0

License

GPL (>= 3)

Maintainer

Florian Hartig

Last Published

June 5th, 2018

Functions in DHARMa (0.2.0)

getRandomState

Record and restore a random state
DHARMa

DHARMa - Residual Diagnostics for HierArchical (Multi-level / Mixed) Regression Models
testTemporalAutocorrelation

Test for temporal autocorrelation
testSpatialAutocorrelation

Test for spatial autocorrelation
createDHARMa

Convert simulated residuals or posterior predictive simulations to a DHARMa object
plotSimulatedResiduals

DHARMa standard residual plots
testDispersion

DHARMa dispersion tests
plotResiduals

Generic residual plot with either spline or quantile regression
refit.glmmTMB

Refit a Model with a Different Response
simulateResiduals

Create simulated residuals
createData

Simulate test data
refit.lm

Refit a Model with a Different Response
testUniformity

Test for overall uniformity
fitted.gam

This function overwrites the standard fitted function for GAM
testGeneric

Generic simulation test of a summary statistic
testZeroInflation

Tests for zero-inflation
testSimulatedResiduals

Residual tests
testOverdispersion

Simulated overdisperstion tests
testResiduals

DHARMa general residual test
plotQQunif

Quantile-quantile plot for a uniform distribution
plot.DHARMa

DHARMa standard residual plots
plotConventionalResiduals

Conventional residual plot
print.DHARMa

Print simulated residuals
runBenchmarks

Benchmark calculations
residuals.DHARMa

Return residuals of a DHARMa simulation
recalculateResiduals

Recalculate residuals with grouping
testOverdispersionParametric

Parametric overdisperstion tests
testPDistribution

Plot distribution of p-values