Free Access Week-  Data Engineering + BI
Data engineering and BI courses are free!
Free AI Access Week from June 2-8

⚠️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,616

Version

0.2.3

License

GPL (>= 3)

Maintainer

Last Published

February 12th, 2019

Functions in DHARMa (0.2.3)

DHARMa

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

Simulate test data
testResiduals

DHARMa general residual test
fitted.gam

This function overwrites the standard fitted function for GAM
testDispersion

DHARMa dispersion tests
simulateResiduals

Create simulated residuals
testSimulatedResiduals

Residual tests
plotResiduals

Generic residual plot with either spline or quantile regression
plotSimulatedResiduals

DHARMa standard residual plots
testGeneric

Generic simulation test of a summary statistic
testModel

Test DHARMa compatibility
plotConventionalResiduals

Conventional residual plot
plotQQunif

Quantile-quantile plot for a uniform distribution
residuals.DHARMa

Return residuals of a DHARMa simulation
getQuantile

Quantile calculations
runBenchmarks

Benchmark calculations
getRandomState

Record and restore a random state
hist.DHARMa

Histogram of DHARMa residuals
plot.DHARMa

DHARMa standard residual plots
testOutliers

Test for outliers
testOverdispersion

Simulated overdisperstion tests
testUniformity

Test for overall uniformity
testZeroInflation

Tests for zero-inflation
getResponse

Get model response
getSimulations

Get model simulations
refit.glmmTMB

Refit a Model with a Different Response
refit.lm

Refit a Model with a Different Response
testSpatialAutocorrelation

Test for spatial autocorrelation
testTemporalAutocorrelation

Test for temporal autocorrelation
checkDots

Check dot operator
createDHARMa

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

Print simulated residuals
recalculateResiduals

Recalculate residuals with grouping
testOverdispersionParametric

Parametric overdisperstion tests
testPDistribution

Plot distribution of p-values
DHARMa.ecdf

Modified ECDF function