Skip to contents

Check model for independence of residuals, i.e. for autocorrelation of error terms.

Usage

check_autocorrelation(x, ...)

# Default S3 method
check_autocorrelation(x, nsim = 1000, ...)

# S3 method for class 'performance_simres'
check_autocorrelation(x, time = NULL, ...)

Arguments

x

A model object, or an object returned by simulate_residuals().

...

Currently not used for models. For simulated residuals, arguments are passed to DHARMa::testTemporalAutocorrelation().

nsim

Number of simulations for the Durbin-Watson-Test.

time

A vector with time values to specify the temporal order of the data. Only used if x is an object returned by simulate_residuals() or by DHARMa.

Value

Invisibly returns the p-value of the test statistics. A p-value < 0.05 indicates autocorrelated residuals.

Details

Performs a Durbin-Watson-Test to check for autocorrelated residuals. In case of autocorrelation, robust standard errors return more accurate results for the estimates, or maybe a mixed model with error term for the cluster groups should be used.

See also

Examples

m <- lm(mpg ~ wt + cyl + gear + disp, data = mtcars)
check_autocorrelation(m)
#> OK: Residuals appear to be independent and not autocorrelated (p = 0.338).