bypass aliased variables in granger causality and run anyway

Apologies if this is the wrong place to post. I'm very new here.

I'm running granger causality analysis in R/RStudio the function grangertest() but am encountering an error about the model containing aliased variables. The error reads : "Error in waldtest.lm(fm, 2, ...) : there are aliased coefficients in the model".

From my understanding, this occurs when there is multicolinearity in the data. I would like to bypass this error if possible and run the model anyway. From some reading, it appears that setting a parameter "singular.ok=TRUE" allows for this, but I have been unable to get it to work or am missing something. I would be very grateful if someone could provide a solution to my problem.

Below is a minimal working example to reproduce the error. My real data contains many more variables and much longer, but if there is a way to get the minimal example to run, I should be able to upscale it as needed.

x <- c(0,1,2,3,4,5)
y <- c(0,3,6,9,12,15)
grangertest(x,y,1) #  This currently produces an error, but I would like to bypass the error and for it to run anyway. 

Thanks in advance

This happens when the data are all at equally spaced intervals.

#> Loading required package: zoo
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>     as.Date, as.Date.numeric

x <- c(0,1,2,3,4,5)
# made third element non-equidistant
y <- c(0,3,4,9,12,15)
# third positional argument, order, already has a default of 1
#> Granger causality test
#> Model 1: y ~ Lags(y, 1:1) + Lags(x, 1:1)
#> Model 2: y ~ Lags(y, 1:1)
#>   Res.Df Df      F Pr(>F)
#> 1      2                 
#> 2      3 -1 4.1208 0.1795

Created on 2021-01-15 by the reprex package (v0.3.0.9001)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.