[R] grangertest/lmtest ... what am I doing wrong ?

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Aug 18 00:33:06 CEST 2008


On Sun, 17 Aug 2008, tolga.i.uzuner at jpmorgan.com wrote:

> Dear Achim, R Users,
>
> What am I doing wrong in this example ?

The Granger test of x and y with lag k tests the significance of the x 
variables in
   y ~ Lags(y, 1:k) + Lags(x, 1:k)
If x is already a lag of y (as in your example), this is not really 
meaningful. In the "lmtest" implementation, it leads to collinearities. 
I'm not sure what MSBVAR does to resolve that.
Z

> a<-zoo(rnorm(100),order.by=1:100)
> b<-lag(a)
> regr<-na.exclude(merge(a,b))
> plot(regr)
> grangertest(regr[,1],regr[,2],3)
>
>> a<-zoo(rnorm(100),order.by=1:100)
>> b<-lag(a)
>> regr<-na.exclude(merge(a,b))
>> plot(regr)
>> grangertest(regr[,1],regr[,2],3)
> Error in solve(vc[ovar, ovar]) : subscript out of bounds
>>
>
> This works fine in granger.test from the MSBVAR package:
>
>> a<-zoo(rnorm(100),order.by=1:100)
>> b<-lag(a)
>> regr<-na.exclude(merge(a,b))
>> plot(regr)
>> granger.test(regr,3)
>        F-statistic   p-value
> b -> a 1.259314e+34 0.0000000
> a -> b 6.167865e-01 0.6059222
>>
>
> Thanks in advance,
> Tolga
>
> Generally, this communication is for informational pur...{{dropped:30}}



More information about the R-help mailing list