[R] dw statistic
Rui Cerqueira
ruimanuelcerqueira at hotmail.com
Wed Nov 21 13:09:12 CET 2001
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.
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list