I'd like to get some help for rolling window vector error correction model (VECM) estimation in R. I have a data of almost 1600 observations and I would like to estimate the VECM by using a rolling window that consists of let's say 300 observations. (First three estimation windows should be [1:300], [2:301], [3:302], ...)
I'd like to collect the error correction coefficients of every estimation window and observe how they change in time. I'm not so familiar with R.
I have already used rollapplyr method and one form of the code I have used goes like this:
vec <- function(x) lineVar(x, lag=1, include="const", model="VECM", estim="ML")
rollapplyr(data5, 300, vec, by.column = FALSE )
or alternatively:
vec <- function(x) c(VECM(x, lag=2, r = 1, include = c("const", "trend", "none", "both"), beta = NULL, estim = c("2OLS", "ML"), LRinclude = c("none", "const","trend", "both"), exogen = NULL))
rollapplyr(data5, 300, vec, by.column = FALSE )
However, these gives me this for every row:
[1,] Numeric,2796 Numeric,8 2 1398 1400 8 4 "linear" Numeric,2796 Numeric,5592 "const" 1 Numeric,8400 1394 FALSE 0
[2,] Numeric,2796 Numeric,8 2 1398 1400 8 4 "linear" Numeric,2796 Numeric,5592 "const" 1 Numeric,8400 1394 FALSE 0
[3,] Numeric,2796 Numeric,8 2 1398 1400 8 4 "linear" Numeric,2796 Numeric,5592 "const" 1 Numeric,8400 1394 FALSE 0
...
And this:
model.specific
[1,] List,9
[2,] List,9
[3,] List,9
....
This rollapplyr method works when I use simple linear regression model. However, when I'm trying to estimate VECM this seems not be the case. What should I do?