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

Ronggui Huang ronggui.huang at gmail.com
Tue Aug 4 15:33:37 CEST 2009


I think the statistics are the same, but the p-values are not exactly
the same as they used different methods for the p-value. car uses
bootstrapping and lmtest uses the "pan" algorithm, said from the help
pages.


2009/8/4 Tom La Bone <booboo at gforcecable.com>:
>
> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html




More information about the R-help mailing list