I recently started playing around with the tsDyn package for R and successfully used it to estimate a bunch of VEC models and print their impulse responses (IRF) and error variance decompositions (FEVD). While I really like its intuitive and straightforward functions, one thing I have not been able to figure out is how to conduct diagnostic tests for a VEC model in tsDyn, specifically tests for serial correlation and ARCH effects?
I tried to convert a tsDyn-generated VEC model to a VAR in levels using the vec2var()
function to apply the serial.test()
and arch.test()
functions from the vars package, but this failed, presumably because vec2var()
doesn't know how to handle classes produced by tsDyn. Since I am unsure whether this is the correct approach in the first place, I was hoping someone here may be able to give advice on the issue.
Here is what I did after loading library(tsDyn)
and library(vars)
:
data(barry) ve <- VECM(barry, lag=1, estim="ML") serial.test(ve) Error in serial.test(ve) : Please provide an object of class 'varest', generated by 'var()', or an object of class 'vec2var' generated by 'vec2var()'. vec2var(ve) Error in vec2var(ve) : Please, provide object of class 'ca.jo' as 'z'. In addition: Warning message: In if (!(class(z) == "ca.jo")) { : the condition has length > 1 and only the first element will be used
Best Answer
You need to convert yourself the VECM into a class recognised by urca, using the function vec2var.tsDyn which is however (currently) not exported, so you need the unusual construction: tsDyn:::vec2var.tsDyn. And then can apply (most of) the vars/urca functions:
library(tsDyn);library(vars) data(barry) ve <- VECM(barry, lag=1, estim="ML") ve_urca <- tsDyn:::vec2var.tsDyn(ve) serial.test(ve_urca)
Gives you (in this case) the same result than using ca.jo directly:
ve_ur <- ca.jo(barry, K=2, spec="transitory") var_ur <- vec2var(ve_ur) serial.test(var_ur)
Best
Similar Posts:
- Solved – Prediction from VECM in R using external forecasts of regressors
- Solved – Prediction from VECM in R using external forecasts of regressors
- Solved – Why does ca.jo has a minimum lag order of 2
- Solved – How to test model misspecification using Johansen test
- Solved – Why is there a need to do OLS regression of VECM