[R] dw statistic

Achim Zeileis zeileis at ci.tuwien.ac.at
Wed Nov 21 13:38:30 CET 2001


Rui Cerqueira wrote:
> 
>   Hello Uwe
> 
>   First, I want to thank you for spending your time replying to my mail. I'm
> very impressed with the speed that my question was answered.
> I'm new at R (about two weeks) and reading your mail made me realize that it
> was indeed a question of vectors of different lengths. I thinked that I
> could create a function ("carfun") without creating a "x" vector, since the
> only purpose of that function is to be integrated right away in the same "x"
> (I re-posted my function again at the end).
>   But now I have another question: since "x" must be of "(dw-eigen)"'s
> length, how can I create a polynom in "x" of variable degree
> (=length("(dw-eigen)")) to be integrated? The computation of the exact
> p-value of DW is a hard one (since it depends on X matrices and the formula
> is a bit complicated), but the DW statistic is a valuable calculation in
> econometrics. The package "lmtest" has a function "dwtest", but it doesn't
> give any p-value.

Not yet. We're still working on the last refinements of a new version of
"lmtest", hopefully out on CRAN by the end of the month.
For the moment you can either use the function durbin.watson() in "car",
which gives a bootstrapped p-value or I could send you a snapshot of the
forthcoming "lmtest", which calculates the p-values with the "pan" or
"gradsol" algorithm (which seems to be quite similar to your approach).
Best,
Z


>   Thank you once more.
> 
> > > »dwf0 <- function(dw,eigen) { carfun <- function(x) {
> > >
> >(prod(1+2*(eigen-dw)*1i*x)^(-1/2)-prod(1-2*(eigen-dw)*1i*x)^(-1/2))/(1i*x)
> >}
> > > ; 1/2+integrate(f=carfun,lower = 0,upper = Inf,
> > > subdivisions=10000)$value/(2*pi) }
> 
> _________________________________________________________________
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list