dw.test: Durbin-Watson Test on AR(1) Autocorrelation

dw.testR Documentation

Durbin-Watson Test on AR(1) Autocorrelation

Description

Durbin-Watson Test on AR(1) autocorrelation of errors in a linear model. The object of test results returned by this command can be plotted using the plot() function.

Usage

dw.test(
  mod,
  data = list(),
  dir = c("left", "right", "both"),
  method = c("pan1", "pan2", "paol", "spa"),
  crit.val = TRUE,
  sig.level = 0.05,
  details = FALSE,
  hyp = TRUE
)

Arguments

mod

estimated linear model object or formula describing the model.

data

if mod is a formula then the corresponding data frame has to be specified.

dir

direction of the alternative hypothesis: "right" for rho > 0, "left" for rho < 0 and "both" for rho <> 0.

method

algorithm used to calculate the p-value. "pan1" and "pan2" are two implementations of Imhof's (1961) algorithm. If they provide a p-values, it is the exact one. "paol" is Paoella's (2007) re-implementation of Imhof's theory, "spa" is a saddle point approximation, also implemented by Paoella (2007).

crit.val

logical value indicating whether the critical value should be calculated.

sig.level

significance level. Default value: sig.level = 0.05.

details

logical value indicating whether specific details about the test should be returned.

hyp

logical value indicating whether the Hypotheses should be returned.

Value

A list object including:

hyp character matrix of hypotheses (if hyp = TRUE).
results a data frame of basic test results, including critical- and p-value.
nulldist type of the null distribution (for internal use).

References

Durbin, J. & Watson, G.S. (1950): Testing for Serial Correlation in Least Squares Regression I. Biometrika 37, 409-428.

Paolella (2007): Intermediate Probability - A Computational Approach, Wiley.

See Also

ddw, pdw.

Examples

## Estimate a simple model
filter.est <- ols(sales ~ price, data = data.filter)

## Perform Durbin Watson test for positive autocorrelation rho > 0 (i.e. d < 2)
test.results <- dw.test(filter.est)

## Print the test results
test.results

## Calculate DW null-distribution and plot the test results
plot(test.results)


desk documentation built on May 29, 2024, 6:05 a.m.

Related to dw.test in desk...