Open gergelybat opened 2 years ago
Hi, thanks for reporting this. Can you please post instead a reprex, in particular with the TVECM code you have issues with?
Thanks
library(tsDyn)
set.seed(1234) N <- 1000 x1 <- cumsum(rnorm(N)) x2 <- 3*x1 + rnorm(N) m_lineVar <- tsDyn::lineVar(cbind(x1,x2), lag=1, include="none", model="VECM") VECM.sim(B=coef(m_lineVar), beta=coefB(m_lineVar), lag=m_lineVar$lag, include=m_lineVar$include, varcov=var(m_lineVar$residuals), starting=(m_lineVar$model[1000,1:2]), n=4)
ok, thanks! I'll have ot check this, might take some time unfortunately. Thanks for reporting!
Hello,
I am fitting a VECM(lag=1) model with 2 variables, and than I run simulations using parameters of that model. My starting values for the simulation should be the last values of the original series.
According to the error messages of TVECM.sim starting values "Should have nrow = lag and ncol = number of variables". So I provide a 1 x 2 matrix as a starting value (I take the last row of the original timeseries).
In the results of the simulation I can see:
I've checked the code of TVECM.sim, and it seems, that indeed simulations begins from i=lag+2. I believe the problem is, that starting values should have rather lag+1 x k dimensions instead of lag x k dimensions.
I was able to make my simulation realistic by changing 2 rows in TVECM.sim function (but please don't assume it's a sure fix, I'm just rather following what dim VECMsim_unrealistic_simulation.R.txt ensions of matrices suggest).
The changes are in the initialization of simulation (changing p -> p+1):
I have no issues simulating VAR models (VAR.sim). Converting VECM models to VAR (VARrep function) and then using VAR.sim also works.
Attached is an example of fitting VECM than simulating. EDIT: x4 should be x2 in the attached code (I'm not able to modify attachment).
Than you, Greg
VECMsim_unrealistic_simulation.R.txt