Solved – How to test for serial correlation and ARCH effect in R package tsDyn

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 '' as 'z'.   In addition: Warning message:   In if (!(class(z) == "")) { :     the condition has length > 1 and only the first element will be used 

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 directly:

ve_ur <-, K=2, spec="transitory") var_ur <- vec2var(ve_ur) serial.test(var_ur) 


Similar Posts:

Rate this post

Leave a Comment