Granger causality

43 views
Skip to first unread message

S.yahya Abtahi

unread,
May 16, 2018, 12:00:55 PM5/16/18
to tsdyn
hi
how can i do perform Granger causality in TVAR code?
best regards.
s.yahya

Matthieu S

unread,
May 16, 2018, 1:30:38 PM5/16/18
to ts...@googlegroups.com, S.yahya Abtahi
Hi

There is no Granger test implemented straight out of the box, but as it is usually testes using the Wald test you can do it rather easily. Extracting the var-cov matrix is with vcov(), and to get the coefs in a vector, use function below.

Let me know how that goes for you!?

library(tsDyn)
data(zeroyld)
tv <- TVAR(zeroyld, lag=1, nthresh=1, thDelay=1, trim=0.1, mTh=1, plot=TRUE)

coefVec <- function(x){
  coef_M <- x$coeffmat
  coef_c <- matrix(t(coef_M), ncol=1, byrow = FALSE)
  rownames(coef_c) <- paste(colnames(coef_M), rep(rownames(coef_M), each=ncol(coef_M)))
  coef_c
}

## wald test for all zero:
t(coefVec(x=tv))%*% vcov(tv) %*% coefVec(x=tv)


Matthieu




--
You received this message because you are subscribed to the Google Groups "tsdyn" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tsdyn+unsubscribe@googlegroups.com.
To post to this group, send email to ts...@googlegroups.com.
Visit this group at https://groups.google.com/group/tsdyn.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages