dwtest
{lmtest}
Description
Performsthe Durbin-Watson test for autocorrelation of disturbances.
Usage
dwtest(formula,order.by = NULL, alternative = c("greater", "two.sided","less"), iterations = 15,exact = NULL, tol = 1e-10, data = list())
Arguments
formula a symbolicdescription for the model to be tested (or a fitted "lm" object).
order.by Either avector z or a formula with a single explanatory variable like ~ z. Theobservations in the model are ordered by the size of z. If set to NULL (thedefault) the observations are assumed to be ordered (e.g., a time series).
alternative a characterstring specifying the alternative hypothesis.
iterations an integer specifying the number ofiterations when calculating the p-value with the "pan" algorithm.
exact logical.If set to FALSE a normal approximation will be used to compute the p value, ifTRUE the "pan" algorithm is used. The default is to use"pan" if the sample size is < 100.
tol tolerance. Eigenvalues computed have tobe greater than tol to be treated as non-zero.
data an optional data frame containing thevariables in the model. By default the variables are taken from the environmentwhich dwtest is called from.
Details
TheDurbin-Watson test has the null hypothesis that the autocorrelation of thedisturbances is 0. It is possible to test against the alternative that it isgreater than, not equal to, or less than 0, respectively. This can be specifiedby the alternative argument.
Underthe assumption of normally distributed disturbances, the null distribution ofthe Durbin-Watson statistic is the distribution of a linear combination ofchi-squared variables. The p-value is computed using a Fortran version of theApplied Statistics Algorithm AS 153 by Farebrother (1980, 1984). This algorithmis called "pan" or "gradsol". For large sample sizes thealgorithm might fail to compute the p value; in that case a warning is printedand an approximate p value will be given; this p value is computed using anormal approximation with mean and variance of the Durbin-Watson teststatistic.
Examplescan not only be found on this page, but also on the help pages of the data setsbondyield, currencysubstitution, growthofmoney, moneydemand, unemployment,wages.
Foran overview on R and econometrics see Racine & Hyndman (2002).
Value
Anobject of class "htest" containing: statistic the test statistic.
p.value the corresponding p-value.
method a characterstring with the method used.
data.name a character string with the data name.
See Also
LmExamples
## generate two AR(1) error terms withparameter
## rho = 0 (white noise) and rho = 0.9respectively
err1<- rnorm(100)
## generate regressor and dependentvariable
x<- rep(c(-1,1), 50)
y1<- 1 + x + err1
## perform Durbin-Watson test
dwtest(y1~ x)
err2<- filter(err1, 0.9, method="recursive")
y2<- 1 + x + err2
dwtest(y2~ x)