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")

Copy Link

Version

Install

install.packages('DHARMa')

Monthly Downloads

15,698

Version

0.4.6

License

GPL (>= 3)

Maintainer

Florian Hartig

Last Published

September 8th, 2022

Functions in DHARMa (0.4.6)

getObservedResponse

Get model response
getQuantile

calculate quantiles
getFixedEffects

Extract fixed effects of a supported model
getSimulations

Get model simulations
getRandomState

Record and restore a random state
getFitted

Get fitted / predicted values
getResiduals

Get model residuals
getPossibleModels

get possible models
getRefit

Get model refit
hist.DHARMa

Histogram of DHARMa residuals
plotConventionalResiduals

Conventional residual plot
plotResiduals

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

Hurricanes
plotQQunif

Quantile-quantile plot for a uniform distribution
plotSimulatedResiduals

DHARMa standard residual plots
outliers

Return outliers
print.DHARMa

Print simulated residuals
recalculateResiduals

Recalculate residuals with grouping
plot.DHARMa

DHARMa standard residual plots
plot.DHARMaBenchmark

Plots DHARMa benchmarks
runBenchmarks

Benchmark calculations
testOverdispersionParametric

Parametric overdisperstion tests
residuals.DHARMa

Return residuals of a DHARMa simulation
testCategorical

Test for categorical dependencies
simulateLRT

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

Simulated overdisperstion tests
simulateResiduals

Create simulated residuals
testGeneric

Generic simulation test of a summary statistic
testDispersion

DHARMa dispersion tests
testOutliers

Test for outliers
testTemporalAutocorrelation

Test for temporal autocorrelation
testResiduals

DHARMa general residual test
testUniformity

Test for overall uniformity
testPDistribution

Plot distribution of p-values
testSpatialAutocorrelation

Test for distance-based (spatial, phylogenetic or similar) autocorrelation
testQuantiles

Test for quantiles
transformQuantiles

Transform quantiles to pdf (deprecated)
testZeroInflation

Tests for zero-inflation
testSimulatedResiduals

Residual tests
benchmarkRuntime

Benchmark runtimes of several functions
createDHARMa

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

Check dot operator
DHARMa

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

Modified ECDF function
ensurePredictor

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

Ensures that an object is of class DHARMa
createData

Simulate test data
checkModel

Check if the fitted model is supported by DHARMa
checkSimulations

Check simulated data