Ignoring Y with known X using VECM in R

I am trying to represent time series data (Y) using a different time series (X) as a predictor. X and Y are cointegrated. Y is monthly data from January 2012 to October 2016, and X is from January 2012 to February 2017.

So, I ran VECM as shown in this video: https://www.youtube.com/watch?v=x9DcUA9puY0

Then, to get the predicted values, I converted it to VAR with the command vec2var

following information from this topic: https://stats.stackexchange.com/questions/223888/how-to-forecast-from-vecm-in-r

But I cannot predict Y with known X, as can be done with a function predict

with a linear regression model. Also, I cannot get the simulated Y (Y hat) values.

This is my code:

# Cointegrated_series is a ZOO object, which contains two time series X and Y

library("zoo") 
library("xts") 
library("urca")
library("vars")

# Obtain lag length
Lagl <- VARselect(Cointegrated_series)$selection[[1]]

#Conduct Eigen test
cointest <- ca.jo(Cointegrated_series,K=Lagl,type = "eigen", ecdet = "const", 
                    spec = "transitory")
#Fit VECM
vecm <- cajorls(cointest)

#Transform VECM to VAR
var <- vec2var(cointest)

      

What I'm trying to use a function predict

in different ways: predict(var)

, predict(var, newdata = 50)

, predict(var, newdata = 1000)

- the result is the same.

Tried using tsDyn

package and newdata

argument in method predict

as he mentioned here: https://stats.stackexchange.com/questions/261849/prediction-from-vecm-in-r-using-external-forecasts-of-regressors?rq=1

Does not work. My newdata is a ZOO object where X-series is from November 2016 to February 2017 and Y-series is NA. Thus, the method returns NA in the forecast:

    # Cointegrated_series is a ZOO object, which contains 
#two time series X and Y from Jan 2012 to Oct 2016. Both X and Y are values.
    # newDat is a ZOO object, which contains two time series 
#X and Y from Nov 2016 to Feb 2017. X are values, Y are NAs.

    library(tsDyn)

    vecm <-VECM(Cointegrated_series, lag=2)

    predict(vecm,newdata = newDat, n.ahead=5)

      

This is the result:

                                                    Y             X
59                                                  NA            NA
60                                                  NA            NA
61                                                  NA            NA
62                                                  NA            NA
63                                                  NA            NA

      

For example, this is what I get after calling the predict

whithout argument newdata

:

predict(vecm, n.ahead=5)

                                              Y             X
59                                            65.05233      64.78006
60                                            70.54545      73.87368
61                                            75.65266      72.06513
62                                            74.76065      62.97242
63                                            70.03992      55.81045

      

So my main questions are:

  • How do I now run Y with a known X using the VEC model in R?
  • How do I get the simulated Y values ​​(Y hat)?

Also, I couldn't find the answer to these questions either:

  1. What to call the Akaike criteria (AIC) for VECM in R?

  2. Are there vars and urca packages for F and t statistics for VECM?

UPD 04/10/2017 I slightly edited the question. It is noticed that my problem is related to the problem of "dangling edge", and it is incorrect to call it "forecasting" - it is "forecasting".

UPD 11.04.2017

Thanks for answering!

Here's the complete code:

library("lubridate")
library("zoo")
library("xts") 
library("urca")
library("vars")
library("forecast") 



Dat <- dget(file = "https://getfile.dokpub.com/yandex/get/https://yadi.sk/d/VJpQ75Rz3GsDKN")
NewDat <- dget(file = "https://getfile.dokpub.com/yandex/get/https://yadi.sk/d/T7qxxPUq3GsDLc")



Lagl <- VARselect(Dat)$selection[[1]]

#vars package

cointest_e <- ca.jo(Dat,K=Lagl,type = "eigen", ecdet = "const", 
                    spec = "transitory")


vecm <- cajorls(cointest_e)

var <- vec2var(cointest_e)

Predict1 <- predict(var)

Predict2 <- predict(var, newdata = NewDat)

Predict1$fcst$Y
Predict2$fcst$Y

Predict1$fcst$Y == Predict2$fcst$Y
Predict1$fcst$X == Predict2$fcst$X

#As we see, Predict1 and Predict2 are similar, so the information in NewDat
#didn't came into account.

library("tsDyn")

vecm2 <-VECM(Dat, lag=3)

predict(vecm2)
predict(vecm2, newdata=NewDat)

      

If it dget

returns an error, please upload my details here:

https://yadi.sk/d/VJpQ75Rz3GsDKN - for Dat

https://yadi.sk/d/T7qxxPUq3GsDLc - for NewDat

About nowcasting

Saying Nowcasting I mean current or previous months projections of unavailable data with currently available data. Here are some links:

Gianonne, Reichlin, Small: Nowcasting: Information Content of Real-Time Macroeconomic Data (2008)

Now-Casting and Real Time Data Stream (2013)

Marcelino, Schumacher: The MIDAS Factor for Nowcasting and Forecasting Using Edged Data: A Comparison of Models for German GDP (2010)

+3


source to share


1 answer


I feel like your question is more about how to do the current prediction for cointegrated variables, then let's see later how to implement it in R.

In general, according to the Granger representation theorem, cointegrated variables can be represented in several forms:

  • Long-term relationship: simultaneous y and x values

  • VECM representation: (diff) y and x due to (difference) lags, and error correction period in the previous period.



So I'm not sure how you will make predictions in the VECM view since it only includes past values? I see two possibilities:

  • Make a forecast of the present weather based on long term relationships. So you just run the standard OLS and predict from there.

  • Make a present weather forecast based on a structural VECM where you add the current values ​​of the variables you know (X). In R you make this package urca

    , you need to check if the function will allow you to predict

    add X icon values.

Regarding the long-term relationship approach, what is interesting is that you can get predictions for X and Y based on VECM (no known X) and from LT with known X. This gives you the ability to get an idea of ​​the accuracy of your model (comparison of known and predicted X), which you could use to create a prediction averaging scheme for your Y?

+2


source







All Articles