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.7

License

GPL (>= 3)

Maintainer

Florian Hartig

Last Published

February 6th, 2020

Functions in DHARMa (0.2.7)

getResponse

Get model response
DHARMa.ecdf

Modified ECDF function
createData

Simulate test data
print.DHARMa

Print simulated residuals
checkDots

Check dot operator
getQuantile

Quantile calculations
refit.glmmTMB

Refit a Model with a Different Response
plot.DHARMa

DHARMa standard residual plots
hist.DHARMa

Histogram of DHARMa residuals
testOverdispersionParametric

Parametric overdisperstion tests
recalculateResiduals

Recalculate residuals with grouping
refit.lm

Refit a Model with a Different Response
testPDistribution

Plot distribution of p-values
testGeneric

Generic simulation test of a summary statistic
testModel

Test DHARMa compatibility
plotQQunif

Quantile-quantile plot for a uniform distribution
testOverdispersion

Simulated overdisperstion tests
plotResiduals

Generic residual plot with either spline or quantile regression
plotConventionalResiduals

Conventional residual plot
testOutliers

Test for outliers
testSpatialAutocorrelation

Test for spatial autocorrelation
testTemporalAutocorrelation

Test for temporal autocorrelation
getRandomState

Record and restore a random state
testUniformity

Test for overall uniformity
testZeroInflation

Tests for zero-inflation
simulateResiduals

Create simulated residuals
testDispersion

DHARMa dispersion tests
transformQuantiles

Transform quantiles to pdf
residuals.DHARMa

Return residuals of a DHARMa simulation
plotSimulatedResiduals

DHARMa standard residual plots
runBenchmarks

Benchmark calculations
testResiduals

DHARMa general residual test
testSimulatedResiduals

Residual tests
fitted.gam

This function overwrites the standard fitted function for GAM
getSimulations

Get model simulations
createDHARMa

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

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