R Under development (unstable) (2024-10-28 r87274 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(tsDyn) > suppressMessages(library(dplyr)) > library(purrr) > library(tidyr) > select <- dplyr::select > suppressWarnings(RNGversion("3.5.3")) > > ############################ > ### Load data > ############################ > > path_mod_multi <- system.file("testdata/models_multivariate.rds", package = "tsDyn") > > models_multivariate <- readRDS(path_mod_multi) > > models_multivariate %>% + mutate(across(where(is.list), class)) %>% + as.data.frame() %>% + head(12) lag include model object object_vars nthresh 1 1 both VAR list list NA 2 1 const VAR list list NA 3 1 none VAR list list NA 4 1 trend VAR list list NA 5 2 both VAR list list NA 6 2 const VAR list list NA 7 2 none VAR list list NA 8 2 trend VAR list list NA 9 1 both VECM list list NA 10 1 const VECM list list NA 11 1 none VECM list list NA 12 1 trend VECM list list NA > > > ############################ > ### VAR > ############################ > > irf_any <- tsDyn:::irf_any > irf_1 <- tsDyn:::irf_1 > irf_1.nlVar <- tsDyn:::irf_1.nlVar > > ## manual comparisons > mod_random_1 <- filter(models_multivariate, lag ==2)$object[[2]] > mod_random_1_vars <- filter(models_multivariate, lag ==2)$object_vars[[2]] > > irf_any(mod_random_1, boot = FALSE)$irf[[1]] dolcan cpiUSA [1,] 0.01279642 -0.0048756343 [2,] 0.01474258 -0.0003293138 [3,] 0.01481730 0.0018693512 [4,] 0.01458848 0.0018642930 [5,] 0.01432107 0.0006853138 [6,] 0.01405581 -0.0010343557 [7,] 0.01379700 -0.0029806380 [8,] 0.01354404 -0.0050076916 [9,] 0.01329620 -0.0070495613 [10,] 0.01305302 -0.0090768908 [11,] 0.01281423 -0.0110768628 > irf(mod_random_1, boot = FALSE)$irf[[1]] dolcan cpiUSA [1,] 0.01279642 -0.0048756343 [2,] 0.01474258 -0.0003293138 [3,] 0.01481730 0.0018693512 [4,] 0.01458848 0.0018642930 [5,] 0.01432107 0.0006853138 [6,] 0.01405581 -0.0010343557 [7,] 0.01379700 -0.0029806380 [8,] 0.01354404 -0.0050076916 [9,] 0.01329620 -0.0070495613 [10,] 0.01305302 -0.0090768908 [11,] 0.01281423 -0.0110768628 > irf(mod_random_1_vars, boot = FALSE)$irf[[1]] dolcan cpiUSA [1,] 0.01279642 -0.0048756343 [2,] 0.01474258 -0.0003293138 [3,] 0.01481730 0.0018693512 [4,] 0.01458848 0.0018642930 [5,] 0.01432107 0.0006853138 [6,] 0.01405581 -0.0010343557 [7,] 0.01379700 -0.0029806380 [8,] 0.01354404 -0.0050076916 [9,] 0.01329620 -0.0070495613 [10,] 0.01305302 -0.0090768908 [11,] 0.01281423 -0.0110768628 > > irf_any(mod_random_1, boot = FALSE, ortho = FALSE)$irf[[1]] dolcan cpiUSA [1,] 1.0000000 0.00000000 [2,] 1.1506724 0.52942976 [3,] 1.1556807 0.77998598 [4,] 1.1374441 0.81507635 [5,] 1.1164438 0.73894786 [6,] 1.0957289 0.61180990 [7,] 1.0755711 0.46302596 [8,] 1.0558941 0.30615552 [9,] 1.0366258 0.14732251 [10,] 1.0177245 -0.01074405 [11,] 0.9991672 -0.16684746 > irf(mod_random_1, boot = FALSE, ortho = FALSE)$irf[[1]] dolcan cpiUSA [1,] 1.0000000 0.00000000 [2,] 1.1506724 0.52942976 [3,] 1.1556807 0.77998598 [4,] 1.1374441 0.81507635 [5,] 1.1164438 0.73894786 [6,] 1.0957289 0.61180990 [7,] 1.0755711 0.46302596 [8,] 1.0558941 0.30615552 [9,] 1.0366258 0.14732251 [10,] 1.0177245 -0.01074405 [11,] 0.9991672 -0.16684746 > irf(mod_random_1_vars, boot = FALSE, ortho = FALSE)$irf[[1]] dolcan cpiUSA [1,] 1.0000000 0.00000000 [2,] 1.1506724 0.52942976 [3,] 1.1556807 0.77998598 [4,] 1.1374441 0.81507635 [5,] 1.1164438 0.73894786 [6,] 1.0957289 0.61180990 [7,] 1.0755711 0.46302596 [8,] 1.0558941 0.30615552 [9,] 1.0366258 0.14732251 [10,] 1.0177245 -0.01074405 [11,] 0.9991672 -0.16684746 > > ### irf _1 > models_IRF_1 <- models_multivariate %>% + filter(model == "VAR") %>% + mutate(irf = map(object, ~irf_1(.))) > > models_IRF_1$irf %>% + bind_rows() %>% + head() %>% + print(digits=3) dolcan cpiUSA impulse 1 1.000 0.000 dolcan 2 0.987 -0.140 dolcan 3 0.974 -0.278 dolcan 4 0.962 -0.414 dolcan 5 0.949 -0.549 dolcan 6 0.937 -0.683 dolcan > > ### irf_any > # irf.NULL <- function(x) NULL > # irf.ca.jo <- function(x) irf(vec2var(ca.jo)) > > models_VAR <- models_multivariate %>% + filter(model == "VAR") > > ## older method > models_IRF_any <- models_multivariate %>% + filter(model == "VAR") %>% + mutate(ortho = list(tibble(ortho =c(TRUE, FALSE)))) %>% + unnest(., ortho) %>% + mutate(irf = map2(object, ortho, ~irf_any(.x, boot = TRUE, runs = 1, seed = 7, ortho = .y)), + irf_vars = map2(object_vars, ortho, ~irf(.x, runs = 1, seed = 7, ortho = .y)), + irf_vec2 = map2(object, ortho, ~irf(.x, boot = FALSE, runs = 1, seed = 7, ortho = .y))) > > models_IRF_any %>% + mutate(across(where(is.list), class)) %>% + as.data.frame() lag include model object object_vars nthresh ortho irf irf_vars irf_vec2 1 1 both VAR list list NA TRUE list list list 2 1 both VAR list list NA FALSE list list list 3 1 const VAR list list NA TRUE list list list 4 1 const VAR list list NA FALSE list list list 5 1 none VAR list list NA TRUE list list list 6 1 none VAR list list NA FALSE list list list 7 1 trend VAR list list NA TRUE list list list 8 1 trend VAR list list NA FALSE list list list 9 2 both VAR list list NA TRUE list list list 10 2 both VAR list list NA FALSE list list list 11 2 const VAR list list NA TRUE list list list 12 2 const VAR list list NA FALSE list list list 13 2 none VAR list list NA TRUE list list list 14 2 none VAR list list NA FALSE list list list 15 2 trend VAR list list NA TRUE list list list 16 2 trend VAR list list NA FALSE list list list > > ## showquick summary > irf_extract_here <- function(x) { + head(x$irf[[1]], 2) %>% + as.data.frame() %>% + mutate(type = "irf") %>% + rbind(head(x$Upper[[1]], 2) %>% + as.data.frame() %>% + mutate(type = "Upper_CI")) %>% + relocate(type) + } > > ## show head of irf any > map_dfr(models_IRF_any$irf, irf_extract_here) %>% + as.data.frame() %>% + head(10)%>% + mutate(across(where(is.numeric), ~round(., 6))) type dolcan cpiUSA 1 irf 0.012960 -0.008008 2 irf 0.012792 -0.009835 3 Upper_CI 0.000000 0.168830 4 Upper_CI 0.000284 0.168505 5 irf 1.000000 0.000000 6 irf 0.987108 -0.139549 7 Upper_CI 0.000000 1.000000 8 Upper_CI 0.001679 0.998075 9 irf 0.012941 -0.007913 10 irf 0.012773 -0.009736 > > > ## compare with vars > all.equal(models_IRF_any$irf[[1]]$irf, + models_IRF_any$irf_vars[[1]]$irf) [1] TRUE > models_IRF_any$irf[[1]]$irf[[1]] dolcan cpiUSA [1,] 0.01296044 -0.008008276 [2,] 0.01279219 -0.009835144 [3,] 0.01262584 -0.011642696 [4,] 0.01246137 -0.013431155 [5,] 0.01229877 -0.015200739 [6,] 0.01213800 -0.016951666 [7,] 0.01197905 -0.018684149 [8,] 0.01182189 -0.020398399 [9,] 0.01166652 -0.022094627 [10,] 0.01151290 -0.023773038 [11,] 0.01136101 -0.025433838 > models_IRF_any$irf_vars[[1]]$irf[[1]] dolcan cpiUSA [1,] 0.01296044 -0.008008276 [2,] 0.01279219 -0.009835144 [3,] 0.01262584 -0.011642696 [4,] 0.01246137 -0.013431155 [5,] 0.01229877 -0.015200739 [6,] 0.01213800 -0.016951666 [7,] 0.01197905 -0.018684149 [8,] 0.01182189 -0.020398399 [9,] 0.01166652 -0.022094627 [10,] 0.01151290 -0.023773038 [11,] 0.01136101 -0.025433838 > models_IRF_any$irf_vec2[[1]]$irf[[1]] dolcan cpiUSA [1,] 0.01296044 -0.008008276 [2,] 0.01279219 -0.009835144 [3,] 0.01262584 -0.011642696 [4,] 0.01246137 -0.013431155 [5,] 0.01229877 -0.015200739 [6,] 0.01213800 -0.016951666 [7,] 0.01197905 -0.018684149 [8,] 0.01182189 -0.020398399 [9,] 0.01166652 -0.022094627 [10,] 0.01151290 -0.023773038 [11,] 0.01136101 -0.025433838 > > comp <- models_IRF_any %>% + mutate(comp_irf_tsD_vars = map2(irf, irf_vars, ~all.equal(.x$irf, .y$irf)), + is_same = map_lgl(comp_irf_tsD_vars, ~isTRUE(.)), + comp_irf_tsDOld_vars = map2(irf_vec2, irf_vars, ~all.equal(.x$irf, .y$irf)), + is_same_tssDvec2 = map_lgl(comp_irf_tsDOld_vars, ~isTRUE(.)), + comp_irf_tsDOld_tsDNew = map2_lgl(irf, irf_vec2, ~all.equal(.x$irf, .y$irf)), + is_same_tsD_2ver = map_lgl(comp_irf_tsDOld_tsDNew, ~isTRUE(.))) %>% + dplyr::select(-starts_with("irf"), -starts_with("comp_irf"), comp_irf_tsDOld_tsDNew) > > comp %>% + dplyr::select(-starts_with("object")) %>% + as.data.frame() lag include model nthresh ortho is_same is_same_tssDvec2 is_same_tsD_2ver 1 1 both VAR NA TRUE TRUE TRUE TRUE 2 1 both VAR NA FALSE TRUE TRUE TRUE 3 1 const VAR NA TRUE TRUE TRUE TRUE 4 1 const VAR NA FALSE TRUE TRUE TRUE 5 1 none VAR NA TRUE TRUE TRUE TRUE 6 1 none VAR NA FALSE TRUE TRUE TRUE 7 1 trend VAR NA TRUE FALSE FALSE TRUE 8 1 trend VAR NA FALSE FALSE FALSE TRUE 9 2 both VAR NA TRUE TRUE TRUE TRUE 10 2 both VAR NA FALSE TRUE TRUE TRUE 11 2 const VAR NA TRUE TRUE TRUE TRUE 12 2 const VAR NA FALSE TRUE TRUE TRUE 13 2 none VAR NA TRUE TRUE TRUE TRUE 14 2 none VAR NA FALSE TRUE TRUE TRUE 15 2 trend VAR NA TRUE FALSE FALSE TRUE 16 2 trend VAR NA FALSE FALSE FALSE TRUE comp_irf_tsDOld_tsDNew 1 TRUE 2 TRUE 3 TRUE 4 TRUE 5 TRUE 6 TRUE 7 TRUE 8 TRUE 9 TRUE 10 TRUE 11 TRUE 12 TRUE 13 TRUE 14 TRUE 15 TRUE 16 TRUE > > ############################ > ### VECM > ############################ > > models_VECM <- models_multivariate %>% + filter(model == "VECM") %>% + mutate(irf = map(object, ~irf_any(., boot = TRUE, runs = 1, seed = 7, ortho = FALSE))) > > ## show two first of first componment > models_VECM %>% + mutate(irf = map(irf, irf_extract_here)) %>% + dplyr::select(-object, -object_vars) %>% + unnest(irf) %>% + as.data.frame() %>% + mutate(across(where(is.numeric), ~round(., 6))) lag include model nthresh type dolcan cpiUSA 1 1 both VECM NA irf 1.000000 0.000000 2 1 both VECM NA irf 1.150497 0.536847 3 1 both VECM NA Upper_CI 0.000000 1.000000 4 1 both VECM NA Upper_CI -0.001956 1.378209 5 1 const VECM NA irf 1.000000 0.000000 6 1 const VECM NA irf 1.158429 0.591890 7 1 const VECM NA Upper_CI 0.000000 1.000000 8 1 const VECM NA Upper_CI -0.001181 1.388875 9 1 none VECM NA irf 1.000000 0.000000 10 1 none VECM NA irf 1.167443 1.150247 11 1 none VECM NA Upper_CI 0.000000 1.000000 12 1 none VECM NA Upper_CI 0.005716 1.823742 13 1 trend VECM NA irf 1.000000 0.000000 14 1 trend VECM NA irf 1.162446 0.746819 15 1 trend VECM NA Upper_CI 0.000000 1.000000 16 1 trend VECM NA Upper_CI -0.000421 1.426727 17 2 both VECM NA irf 1.000000 0.000000 18 2 both VECM NA irf 1.152608 0.652006 19 2 both VECM NA Upper_CI 0.000000 1.000000 20 2 both VECM NA Upper_CI 0.000536 1.445896 21 2 const VECM NA irf 1.000000 0.000000 22 2 const VECM NA irf 1.162481 0.711727 23 2 const VECM NA Upper_CI 0.000000 1.000000 24 2 const VECM NA Upper_CI 0.000778 1.443891 25 2 none VECM NA irf 1.000000 0.000000 26 2 none VECM NA irf 1.171534 1.189804 27 2 none VECM NA Upper_CI 0.000000 1.000000 28 2 none VECM NA Upper_CI 0.001019 1.644230 29 2 trend VECM NA irf 1.000000 0.000000 30 2 trend VECM NA irf 1.167209 0.885486 31 2 trend VECM NA Upper_CI 0.000000 1.000000 32 2 trend VECM NA Upper_CI 0.000896 1.467909 > > > ## plot 1 > plot(models_VECM$irf[[1]]) > > > > ############################ > ### TVAR > ############################ > > > models_TVAR <- models_multivariate %>% + filter(model == "TVAR") > > ## test 1 > tvar_1 <- models_TVAR$object[[1]] > > irf(tvar_1, runs = 2, seed = 123) Impulse response coefficients $dolcan dolcan cpiUSA [1,] 0.012915469 -0.003809746 [2,] 0.012696014 0.005452775 [3,] 0.012458133 0.014587434 [4,] 0.012202462 0.023580589 [5,] 0.011929656 0.032419010 [6,] 0.011640391 0.041089896 [7,] 0.011335361 0.049580889 [8,] 0.011015279 0.057880091 [9,] 0.010680874 0.065976078 [10,] 0.010332889 0.073857911 [11,] 0.009972079 0.081515151 $cpiUSA dolcan cpiUSA [1,] 0.0000000000 0.1603999 [2,] -0.0003863422 0.1609147 [3,] -0.0007670853 0.1611538 [4,] -0.0011416644 0.1611202 [5,] -0.0015095317 0.1608175 [6,] -0.0018701580 0.1602497 [7,] -0.0022230327 0.1594211 [8,] -0.0025676651 0.1583364 [9,] -0.0029035841 0.1570008 [10,] -0.0032303396 0.1554197 [11,] -0.0035475025 0.1535988 Lower Band, CI= 0.05 $cpiUSA dolcan cpiUSA [1,] 0.000000000 0.15574683 [2,] -0.001415551 0.14673544 [3,] -0.002709885 0.13722747 [4,] -0.003881594 0.12734160 [5,] -0.004930428 0.11719020 [6,] -0.005857201 0.10687889 [7,] -0.006663698 0.09650616 [8,] -0.007352591 0.08616311 [9,] -0.007927336 0.07593325 [10,] -0.008392087 0.06589238 [11,] -0.008751603 0.05610859 $dolcan dolcan cpiUSA [1,] 0.013109678 -0.002907084 [2,] 0.012945142 0.010748397 [3,] 0.012640610 0.020697951 [4,] 0.012138876 0.029107229 [5,] 0.011574632 0.036668717 [6,] 0.010957403 0.043387383 [7,] 0.010296409 0.049274807 [8,] 0.009600513 0.054348553 [9,] 0.008878174 0.058631533 [10,] 0.008137405 0.062151381 [11,] 0.007385741 0.064939835 Upper Band, CI= 0.05 $cpiUSA dolcan cpiUSA [1,] 0.0000000000 0.1744308 [2,] -0.0006466191 0.1758129 [3,] -0.0012860284 0.1765828 [4,] -0.0019161469 0.1767409 [5,] -0.0025349603 0.1762896 [6,] -0.0031405233 0.1752329 [7,] -0.0037309615 0.1735766 [8,] -0.0043044738 0.1713282 [9,] -0.0048593344 0.1684968 [10,] -0.0053938944 0.1650932 [11,] -0.0059065841 0.1611299 $dolcan dolcan cpiUSA [1,] 0.013417315 0.00135295 [2,] 0.013070069 0.01144315 [3,] 0.012732954 0.02435132 [4,] 0.012474215 0.03785511 [5,] 0.012170165 0.05121368 [6,] 0.011822183 0.06438159 [7,] 0.011431776 0.07731419 [8,] 0.011000576 0.08996768 [9,] 0.010530334 0.10229931 [10,] 0.010022911 0.11426748 [11,] 0.009480272 0.12583181 > > ## regime specific for TVAR > models_TVAR_irf <- models_TVAR %>% + mutate(irf_L = map(object, ~irf_any(., boot = TRUE, runs = 1, seed = 7, ortho = FALSE, regime = "L"))) > > ## show two first of first componment > models_TVAR_irf %>% + mutate(irf = map(irf_L, irf_extract_here)) %>% + dplyr::select(-object, -object_vars, -irf_L ) %>% + unnest(irf) %>% + as.data.frame() %>% + mutate(across(where(is.numeric), ~round(., 6))) lag include model nthresh type dolcan cpiUSA 1 1 both TVAR 1 irf 1.000000 0.000000 2 1 both TVAR 1 irf 0.982298 0.718112 3 1 both TVAR 1 Upper_CI 0.000000 1.000000 4 1 both TVAR 1 Upper_CI -0.002896 0.993410 5 1 both TVAR 2 irf 1.000000 0.000000 6 1 both TVAR 2 irf 0.982298 0.718112 7 1 both TVAR 2 Upper_CI 0.000000 1.000000 8 1 both TVAR 2 Upper_CI -0.002680 0.995241 9 1 const TVAR 1 irf 1.000000 0.000000 10 1 const TVAR 1 irf 0.993968 1.341579 11 1 const TVAR 1 Upper_CI 0.000000 1.000000 12 1 const TVAR 1 Upper_CI 0.000894 0.995010 13 1 const TVAR 2 irf 1.000000 0.000000 14 1 const TVAR 2 irf 1.031097 0.593753 15 1 const TVAR 2 Upper_CI 0.000000 1.000000 16 1 const TVAR 2 Upper_CI 0.003019 0.983623 17 1 none TVAR 1 irf 1.000000 0.000000 18 1 none TVAR 1 irf 1.001838 0.305646 19 1 none TVAR 1 Upper_CI 0.000000 1.000000 20 1 none TVAR 1 Upper_CI 0.000357 1.002424 21 1 none TVAR 2 irf 1.000000 0.000000 22 1 none TVAR 2 irf 0.999474 0.306317 23 1 none TVAR 2 Upper_CI 0.000000 1.000000 24 1 none TVAR 2 Upper_CI 0.000851 0.999196 25 1 trend TVAR 1 irf 1.000000 0.000000 26 1 trend TVAR 1 irf 1.003846 0.685483 27 1 trend TVAR 1 Upper_CI 0.000000 1.000000 28 1 trend TVAR 1 Upper_CI 0.002103 0.980364 29 1 trend TVAR 2 irf 1.000000 0.000000 30 1 trend TVAR 2 irf 1.028017 0.408567 31 1 trend TVAR 2 Upper_CI 0.000000 1.000000 32 1 trend TVAR 2 Upper_CI -0.000175 0.993426 33 2 both TVAR 1 irf 1.000000 0.000000 34 2 both TVAR 1 irf 1.116408 -0.057891 35 2 both TVAR 1 Upper_CI 0.000000 1.000000 36 2 both TVAR 1 Upper_CI 0.005069 1.179249 37 2 both TVAR 2 irf 1.000000 0.000000 38 2 both TVAR 2 irf 1.116408 -0.057891 39 2 both TVAR 2 Upper_CI 0.000000 1.000000 40 2 both TVAR 2 Upper_CI 0.006126 1.142099 41 2 const TVAR 1 irf 1.000000 0.000000 42 2 const TVAR 1 irf 1.143821 0.835415 43 2 const TVAR 1 Upper_CI 0.000000 1.000000 44 2 const TVAR 1 Upper_CI 0.001238 1.366002 45 2 const TVAR 2 irf 1.000000 0.000000 46 2 const TVAR 2 irf 1.143821 0.835415 47 2 const TVAR 2 Upper_CI 0.000000 1.000000 48 2 const TVAR 2 Upper_CI -0.003818 1.188527 49 2 none TVAR 1 irf 1.000000 0.000000 50 2 none TVAR 1 irf 1.145264 0.662497 51 2 none TVAR 1 Upper_CI 0.000000 1.000000 52 2 none TVAR 1 Upper_CI 0.001583 1.433116 53 2 none TVAR 2 irf 1.000000 0.000000 54 2 none TVAR 2 irf 1.196393 -0.036864 55 2 none TVAR 2 Upper_CI 0.000000 1.000000 56 2 none TVAR 2 Upper_CI 0.000725 1.203324 57 2 trend TVAR 1 irf 1.000000 0.000000 58 2 trend TVAR 1 irf 1.145049 0.703506 59 2 trend TVAR 1 Upper_CI 0.000000 1.000000 60 2 trend TVAR 1 Upper_CI 0.001119 1.396871 61 2 trend TVAR 2 irf 1.000000 0.000000 62 2 trend TVAR 2 irf 1.155769 1.053381 63 2 trend TVAR 2 Upper_CI 0.000000 1.000000 64 2 trend TVAR 2 Upper_CI -0.000626 1.438063 > > > ## plot 1 > plot(models_TVAR_irf$irf_L[[1]]) > > ############################ > ### TVECM > ############################ > > models_TVECM <- models_multivariate %>% + filter(model == "TVECM") > > ## test 1 > tvecm_1 <- models_TVECM$object[[1]] > tsDyn:::irf_1(x=tvecm_1 , n.ahead = 10, cumulative = FALSE, regime = "L", ortho = TRUE) dolcan cpiUSA impulse 1 1.259456e-02 -0.0066571462 dolcan 2 1.412961e-02 0.0004987004 dolcan 3 1.357007e-02 0.0117603211 dolcan 4 1.264754e-02 0.0232666549 dolcan 5 1.171809e-02 0.0340318020 dolcan 6 1.085315e-02 0.0438852790 dolcan 7 1.006270e-02 0.0528540463 dolcan 8 9.343524e-03 0.0610059322 dolcan 9 8.689924e-03 0.0684126651 dolcan 10 8.096086e-03 0.0751417442 dolcan 11 7.556583e-03 0.0812550279 dolcan 12 0.000000e+00 0.1510675271 cpiUSA 13 -1.719667e-03 0.1704146708 cpiUSA 14 -2.018136e-03 0.1700704447 cpiUSA 15 -1.823452e-03 0.1666178104 cpiUSA 16 -1.521100e-03 0.1628643752 cpiUSA 17 -1.215673e-03 0.1593240316 cpiUSA 18 -9.309408e-04 0.1560789723 cpiUSA 19 -6.705814e-04 0.1531244399 cpiUSA 20 -4.336612e-04 0.1504388380 cpiUSA 21 -2.183345e-04 0.1479986866 cpiUSA 22 -2.269402e-05 0.1457817803 cpiUSA > tsDyn:::irf_1(x=tvecm_1 , n.ahead = 10, cumulative = FALSE, regime = "L", ortho = FALSE) dolcan cpiUSA impulse 1 1.0000000000 0.0000000 dolcan 2 1.1158649567 0.6358639 dolcan 3 1.0703936124 1.5288252 dolcan 4 0.9978264483 2.4303404 dolcan 5 0.9250867275 3.2719535 dolcan 6 0.8574797401 4.0419260 dolcan 7 0.7957147322 4.7426864 dolcan 8 0.7395237046 5.3796034 dolcan 9 0.6884572617 5.9582967 dolcan 10 0.6420602816 6.4840435 dolcan 11 0.5999085928 6.9616776 dolcan 12 0.0000000000 1.0000000 cpiUSA 13 -0.0113834300 1.1280695 cpiUSA 14 -0.0133591680 1.1257909 cpiUSA 15 -0.0120704403 1.1029360 cpiUSA 16 -0.0100690100 1.0780899 cpiUSA 17 -0.0080472173 1.0546544 cpiUSA 18 -0.0061624153 1.0331735 cpiUSA 19 -0.0044389510 1.0136159 cpiUSA 20 -0.0028706447 0.9958384 cpiUSA 21 -0.0014452778 0.9796856 cpiUSA 22 -0.0001502243 0.9650107 cpiUSA > irf(x=tvecm_1, runs = 2, seed = 123) Impulse response coefficients $dolcan dolcan cpiUSA [1,] 0.012594557 -0.0066571462 [2,] 0.014129606 0.0004987004 [3,] 0.013570067 0.0117603211 [4,] 0.012647537 0.0232666549 [5,] 0.011718088 0.0340318020 [6,] 0.010853149 0.0438852790 [7,] 0.010062699 0.0528540463 [8,] 0.009343524 0.0610059322 [9,] 0.008689924 0.0684126651 [10,] 0.008096086 0.0751417442 [11,] 0.007556583 0.0812550279 $cpiUSA dolcan cpiUSA [1,] 0.000000e+00 0.1510675 [2,] -1.719667e-03 0.1704147 [3,] -2.018136e-03 0.1700704 [4,] -1.823452e-03 0.1666178 [5,] -1.521100e-03 0.1628644 [6,] -1.215673e-03 0.1593240 [7,] -9.309408e-04 0.1560790 [8,] -6.705814e-04 0.1531244 [9,] -4.336612e-04 0.1504388 [10,] -2.183345e-04 0.1479987 [11,] -2.269402e-05 0.1457818 Lower Band, CI= 0.05 $cpiUSA dolcan cpiUSA [1,] 0.0000000000 0.1518679 [2,] -0.0036766033 0.1329288 [3,] -0.0037303415 0.1320815 [4,] -0.0035104769 0.1372203 [5,] -0.0030529103 0.1408389 [6,] -0.0025695700 0.1439257 [7,] -0.0021164219 0.1468103 [8,] -0.0017035816 0.1494577 [9,] -0.0013298109 0.1518770 [10,] -0.0009918396 0.1526318 [11,] -0.0006863122 0.1503966 $dolcan dolcan cpiUSA [1,] 0.012761098 -0.0122545261 [2,] 0.013166774 0.0001548694 [3,] 0.011317071 0.0094704856 [4,] 0.010186703 0.0001172342 [5,] 0.009204399 -0.0071924029 [6,] 0.008275847 -0.0139656825 [7,] 0.007425881 -0.0202174802 [8,] 0.006650625 -0.0259316579 [9,] 0.005942264 -0.0311576357 [10,] 0.005294965 -0.0359393743 [11,] 0.004703522 -0.0403143296 Upper Band, CI= 0.05 $cpiUSA dolcan cpiUSA [1,] 0.000000e+00 0.1593005 [2,] -3.018230e-03 0.1785313 [3,] -2.967110e-03 0.1765646 [4,] -2.293506e-03 0.1722362 [5,] -1.842602e-03 0.1680351 [6,] -1.417866e-03 0.1642652 [7,] -1.021275e-03 0.1608892 [8,] -6.595127e-04 0.1578498 [9,] -3.292642e-04 0.1551075 [10,] -2.747135e-05 0.1540905 [11,] 2.482834e-04 0.1561159 $dolcan dolcan cpiUSA [1,] 0.012986537 0.001034214 [2,] 0.015124778 0.020232192 [3,] 0.014625889 0.011250617 [4,] 0.013569122 0.020816218 [5,] 0.012474651 0.029261791 [6,] 0.011455171 0.036801019 [7,] 0.010528433 0.043584021 [8,] 0.009689996 0.049703927 [9,] 0.008931985 0.055228841 [10,] 0.008246748 0.060217201 [11,] 0.007627298 0.064721239 > > ## regime specific for TVECM > models_TVECM_irf <- models_TVECM %>% + mutate(irf_L = map(object, ~suppressWarnings(irf_any(., boot = TRUE, runs = 1, seed = 7, ortho = FALSE, regime = "L")))) > > ## show two first of first componment > models_TVECM_irf %>% + mutate(irf = map(irf_L, irf_extract_here)) %>% + select(-object, -object_vars, -irf_L ) %>% + unnest(irf) %>% + as.data.frame() %>% + mutate(across(where(is.numeric), ~round(., 6))) lag include model nthresh type dolcan cpiUSA 1 1 both TVECM 1 irf 1.000000 0.000000 2 1 both TVECM 1 irf 1.115865 0.635864 3 1 both TVECM 1 Upper_CI 0.000000 1.000000 4 1 both TVECM 1 Upper_CI 0.001099 0.992494 5 1 both TVECM 2 irf 1.000000 0.000000 6 1 both TVECM 2 irf 1.115865 0.635864 7 1 both TVECM 2 Upper_CI 0.000000 1.000000 8 1 both TVECM 2 Upper_CI -0.002071 0.795772 9 1 const TVECM 1 irf 1.000000 0.000000 10 1 const TVECM 1 irf 1.087586 0.899218 11 1 const TVECM 1 Upper_CI 0.000000 1.000000 12 1 const TVECM 1 Upper_CI 0.001768 0.899371 13 1 const TVECM 2 irf 1.000000 0.000000 14 1 const TVECM 2 irf 1.087586 0.899218 15 1 const TVECM 2 Upper_CI 0.000000 1.000000 16 1 const TVECM 2 Upper_CI -0.003737 0.945145 17 1 none TVECM 1 irf 1.000000 0.000000 18 1 none TVECM 1 irf 1.095626 0.465547 19 1 none TVECM 1 Upper_CI 0.000000 1.000000 20 1 none TVECM 1 Upper_CI 0.005645 1.653400 21 1 none TVECM 2 irf 1.000000 0.000000 22 1 none TVECM 2 irf 1.142178 1.809654 23 1 none TVECM 2 Upper_CI 0.000000 1.000000 24 1 none TVECM 2 Upper_CI 0.005597 1.745848 25 1 trend TVECM 1 irf 1.000000 0.000000 26 1 trend TVECM 1 irf 1.183445 0.872582 27 1 trend TVECM 1 Upper_CI 0.000000 1.000000 28 1 trend TVECM 1 Upper_CI 0.000343 1.610538 29 1 trend TVECM 2 irf 1.000000 0.000000 30 1 trend TVECM 2 irf 1.078900 1.489184 31 1 trend TVECM 2 Upper_CI 0.000000 1.000000 32 1 trend TVECM 2 Upper_CI -0.002040 0.820806 33 2 both TVECM 1 irf 1.000000 0.000000 34 2 both TVECM 1 irf 1.168665 0.281654 35 2 both TVECM 1 Upper_CI 0.000000 1.000000 36 2 both TVECM 1 Upper_CI -0.001356 1.279373 37 2 both TVECM 2 irf 1.000000 0.000000 38 2 both TVECM 2 irf 1.139679 0.236860 39 2 both TVECM 2 Upper_CI 0.000000 1.000000 40 2 both TVECM 2 Upper_CI -0.008496 1.213897 41 2 const TVECM 1 irf 1.000000 0.000000 42 2 const TVECM 1 irf 1.179502 0.472377 43 2 const TVECM 1 Upper_CI 0.000000 1.000000 44 2 const TVECM 1 Upper_CI 0.004413 1.310172 45 2 const TVECM 2 irf 1.000000 0.000000 46 2 const TVECM 2 irf 1.112088 0.587852 47 2 const TVECM 2 Upper_CI 0.000000 1.000000 48 2 const TVECM 2 Upper_CI -0.008211 1.055222 49 2 none TVECM 1 irf 1.000000 0.000000 50 2 none TVECM 1 irf 1.121259 0.092243 51 2 none TVECM 1 Upper_CI 0.000000 1.000000 52 2 none TVECM 1 Upper_CI 0.010255 1.583673 53 2 none TVECM 2 irf 1.000000 0.000000 54 2 none TVECM 2 irf 1.231963 0.074279 55 2 none TVECM 2 Upper_CI 0.000000 1.000000 56 2 none TVECM 2 Upper_CI 0.015478 1.536769 57 2 trend TVECM 1 irf 1.000000 0.000000 58 2 trend TVECM 1 irf 1.184091 0.748835 59 2 trend TVECM 1 Upper_CI 0.000000 1.000000 60 2 trend TVECM 1 Upper_CI 0.001301 1.348732 61 2 trend TVECM 2 irf 1.000000 0.000000 62 2 trend TVECM 2 irf 1.158615 0.715514 63 2 trend TVECM 2 Upper_CI 0.000000 1.000000 64 2 trend TVECM 2 Upper_CI -0.007753 1.246237 > > > ## plot 1 > plot(models_TVECM_irf$irf_L[[1]]) > > proc.time() user system elapsed 25.89 4.40 30.39