Learn R Programming

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
  • Heteroscedasticity
  • Under/Overdispersion
  • Zero-inflation
  • Residual temporal autocorrelation
  • Residual spatial autocorrelation
  • Residual phylogenetic autocorrelation

To get more information, install the package and run

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

Copy Link

Version

Install

install.packages('DHARMa')

Monthly Downloads

13,478

Version

0.4.7

License

GPL (>= 3)

Maintainer

Last Published

October 18th, 2024

Functions in DHARMa (0.4.7)

plotConventionalResiduals

Conventional residual plot
plotResiduals

Generic res ~ pred scatter plot with spline or quantile regression on top
plotQQunif

Quantile-quantile plot for a uniform distribution
plot.DHARMaBenchmark

Plots DHARMa benchmarks
plot.DHARMa

DHARMa standard residual plots
runBenchmarks

Benchmark calculations
residuals.DHARMa

Return residuals of a DHARMa simulation
plotSimulatedResiduals

DHARMa standard residual plots
getSimulations

Get model simulations
simulateLRT

Simulated likelihood ratio tests for (generalized) linear mixed models
simulateResiduals

Create simulated residuals
hist.DHARMa

Histogram of DHARMa residuals
testGeneric

Test for a generic summary statistic based on simulated data
testOutliers

Test for outliers
testCategorical

Test for categorical dependencies
testDispersion

DHARMa dispersion tests
testSpatialAutocorrelation

Test for distance-based spatial (or similar type) autocorrelation
testZeroInflation

Tests for zero-inflation
transformQuantiles

Transform quantiles to pdf (deprecated)
testOverdispersion

Simulated overdisperstion tests
testSimulatedResiduals

Residual tests
testOverdispersionParametric

Parametric overdisperstion tests
print.DHARMa

Print simulated residuals
testQuantiles

Test for quantiles
getResiduals

Get model residuals
recalculateResiduals

Recalculate residuals with grouping
outliers

Return outliers
hurricanes

Hurricanes
testUniformity

Test for overall uniformity
testTemporalAutocorrelation

Test for temporal autocorrelation
testResiduals

DHARMa general residual test
testPDistribution

Plot distribution of p-values.
testPhylogeneticAutocorrelation

Test for phylogenetic autocorrelation
ensurePredictor

Ensures the existence of a valid predictor to plot residuals against
benchmarkRuntime

Benchmark runtimes of several functions
createDHARMa

Create a DHARMa object from hand-coded simulations or Bayesian posterior predictive simulations.
createData

Simulate test data
getQuantile

Calculate Residual Quantiles
getRefit

Get model refit
getRandomState

Record and restore a random state
getPearsonResiduals

Get Pearson residuals
getFixedEffects

Extract fixed effects of a supported model
getFitted

Get fitted/predicted values
getFamily

Get model family
checkModel

Check if the fitted model is supported by DHARMa
DHARMa-package

DHARMa: Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models
DHARMa.ecdf

Modified ECDF function.
checkDots

Check dot operator
getPossibleModels

get possible models
checkSimulations

Check simulated data
ensureDHARMa

Ensures that an object is of class DHARMa
getObservedResponse

Get model response