# [R] dw statistic

Rui Cerqueira ruimanuelcerqueira at hotmail.com
Wed Nov 21 15:08:08 CET 2001

```Hello Achim

I would appreciate very much the snapshot you told, even for learning
purpose (developing is, in my opinion, a bit soon). Nevertheless, I'm going
to look at the durbin.watson() in "car".
I can't stop saying how admired I am with the quickness my question was
solved. Thanks to all.

>From: Achim Zeileis <zeileis at ci.tuwien.ac.at>
>To: Rui Cerqueira <ruimanuelcerqueira at hotmail.com>
>CC: ligges at statistik.uni-dortmund.de, r-help at stat.math.ethz.ch
>Subject: Re: [R] dw statistic
>Date: Wed, 21 Nov 2001 13:38:30 +0100
>
>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.
>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
>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
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

_________________________________________________________________

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```