0
$\begingroup$

I'm working on using Granger causality of some variables and I have 4 stationary time series (X1, X2, X3, X4) and one that is not (X5). I've seen here that

If (A) then first-difference each of the three variables (x1, x2, x3), and use them together with the stationary variable x4 to build a VAR model.

But if I differenciate the (X5) series, by using VAR in R:

Error in VAR(qq2) : 
 NAs in y.

where qq2 = cbind(X1,X2,X3,X4,X5).

Because I lose one observation in differencing. Do I need to remove one observation from the other series as well?

EDIT: Example provided. Let's assume three series, X1 and X2 stationary. X3 non stationary.

X1  <- arima.sim(model=list(ar=c(.9,-.2)),n=200)
X2  <- arima.sim(model=list(ar=c(.5,-.2)),n=200)
X3  <- arima.sim(list(order = c(1,1,0), ar = 0.7), n = 200)
X3d <- diff(X3)
qq2 <- vars::VAR(cbind(X1,X2,X3d))
$\endgroup$
  • $\begingroup$ CV is not for purely programming related questions. Stack Overflow is probably better. You should preferable provide minimum example so people can replicate the error. That said I would say the answer to your question is "YES". Start by making sure qq2 do not have any NA's by removing one observation from the other series. $\endgroup$ – Jesper Hybel Dec 31 '18 at 14:33
  • $\begingroup$ You don't need to remove anything, you can easily handle the missing observation because a VAR model is trivially a state-space model and can be fitted via Kalman filter. The fact that the specific function vars::VAR (which I'm guessing you are using) does not allow for missing values is because it fits the model with equation-by-equation OLS. $\endgroup$ – Chris Haug Dec 31 '18 at 18:36
  • $\begingroup$ Thanks for the responses! I added an example and yes it's from vars package. I was unsure if CV or Stack Overflow because aside from the R code, I was more interested in a statistical solution for the problem, like: 'how to deal with a mix of stationary and non-stationary time series in the model'. Sorry if I was unclear :) $\endgroup$ – Kol Rocket Jan 1 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.