[R] Comparison of Output from "dwtest" and "durbin.watson"

Tom La Bone booboo at gforcecable.com
Tue Aug 4 15:18:31 CEST 2009


Allow me to reword this question. I have performed two fits to the same set
of data below: a weighted fit and an unweighted fit. I performed the
Durbin-Watson tests on each fit using "dwtest" and "durbin.watson". For a
given fit (weighted or unweighted), should both dwtest and durbin.watson be
giving me the same DW statistic and p-value? Should I get the same DW
statistic and p-value for the weighted and unweighted fits as I do using
dwtest?


> library(lmtest)
Loading required package: zoo

Attaching package: 'zoo'


        The following object(s) are masked from package:base :

         as.Date.numeric 

> library(car)
> X <- c(4.8509E-1,8.2667E-2,6.4010E-2,5.1188E-2,3.4492E-2,2.1660E-2,
+         3.2242E-3,1.8285E-3)
> Y <- c(2720,1150,1010,790,482,358,78,35)
> W <- 1/Y^2
> 
> fit <- lm(Y ~ X - 1)
> dwtest(fit,alternative="two.sided")

        Durbin-Watson test

data:  fit 
DW = 0.7599, p-value = 0.05935
alternative hypothesis: true autocorelation is not 0 

> durbin.watson(fit,alternative="two.sided")
 lag Autocorrelation D-W Statistic p-value
   1       0.5897666     0.7599161   0.368
 Alternative hypothesis: rho != 0
> 
> fit <- lm(Y ~ X - 1,weights=W)
> dwtest(fit,alternative="two.sided")

        Durbin-Watson test

data:  fit 
DW = 0.7599, p-value = 0.05935
alternative hypothesis: true autocorelation is not 0 

> durbin.watson(fit,alternative="two.sided")
 lag Autocorrelation D-W Statistic p-value
   1     -0.07663672      1.209076    0.77
 Alternative hypothesis: rho != 0
> 

-- 
View this message in context: http://www.nabble.com/Comparison-of-Output-from-%22dwtest%22-and-%22durbin.watson%22-tp24783494p24808540.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list