Closed zahrasaranik closed 2 years ago
Hi
To use the new GIRF functionalities, see the paper: Stigler, M. tsDyn: Threshold cointegration: overview and implementation in R, Handbook of Statistics, Volume 42, p. 229-264, link.
Note you will need to use the version in the master
branch: remotes::install_github("MatthieuStigler/tsDyn/tsDyn", ref = "master")
.
Here is some example code:
library(remotes)
remotes::install_github("MatthieuStigler/tsDyn/tsDyn", ref = "master")
#> Skipping install of 'tsDyn' from a github remote, the SHA1 (fba66598) has not changed since last install.
#> Use `force = TRUE` to force installation
library(tsDyn)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
packageVersion("tsDyn")
#> [1] '11.0.0'
?GIRF
data(zeroyld)
exampleTVAR <-TVAR(zeroyld, lag = 3, nthresh = 1, thDelay = 1, mTh = 2, trim = 0.2, plot = FALSE)
#> Best unique threshold 8.199
GIRF_out <- GIRF(exampleTVAR)
head(GIRF_out)
#> n_simu hist_x1_l1 hist_x1_l2 hist_x1_l3 hist_x2_l1 hist_x2_l2 hist_x2_l3
#> 1 1 8.129 7.966 7.868 6.86 6.071 6.849
#> 2 1 8.129 7.966 7.868 6.86 6.071 6.849
#> 3 1 8.129 7.966 7.868 6.86 6.071 6.849
#> 4 1 8.129 7.966 7.868 6.86 6.071 6.849
#> 5 1 8.129 7.966 7.868 6.86 6.071 6.849
#> 6 1 8.129 7.966 7.868 6.86 6.071 6.849
#> shock_var1 shock_var2 n.ahead var sim_1 sim_2 girf
#> 1 0.03258525 0.04724898 0 long.run 6.839640 6.792391 0.04724898
#> 2 0.03258525 0.04724898 1 long.run 7.102490 7.048281 0.05420847
#> 3 0.03258525 0.04724898 2 long.run 7.064325 7.008322 0.05600382
#> 4 0.03258525 0.04724898 3 long.run 6.986697 6.932418 0.05427855
#> 5 0.03258525 0.04724898 4 long.run 7.078099 7.025349 0.05275096
#> 6 0.03258525 0.04724898 5 long.run 7.119340 7.067929 0.05141097
plot(GIRF_out)
Created on 2021-12-06 by the reprex package (v2.0.1)
Thanks so much, I will do that
Hi My name is Fatima, Im Phd student, I have some difficulties in GIRF. I have run this code, but the GIRFs is not correct! what is the problem? I would be gratefull if you could help me.
TVAR.LRtest(takh,lag = 3, mTh = 2, thDelay = 3, nboot = 10,plot = FALSE,trim = 0.2, test = "1vs") Warning: the thDelay values do not correspond to the univariate implementation in tsdyn Test of linear VAR against TVAR(1) and TVAR(2)
LR test: 1vs2 1vs3 Test 236.921 603.3081 P-Val 0.000 0.2000 exampleTVAR<-TVAR(takh, lag = 3, nthresh = 1, thDelay = 1, mTh = 2, trim = 0.2, plot = FALSE) Best unique threshold -0.01276881 GIRF(exampleTVAR,c(0,1,0,0), horizon = 20, H = 200, R = 500, restrict.to = 1) saved_girfs<-GIRF(exampleTVAR,c(0,1,0,0), horizon = 20, H = 200, R = 500, restrict.to = 1) tidy(saved_girfs)
A tibble: 80 x 3
horizon variable response