R Under development (unstable) (2024-10-26 r87273 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)
> library(tibble)
> suppressWarnings(RNGversion("3.5.3"))
> 
> data(IIPUs)
> 
> ### grid ###
> grid <-  crossing(include = c( "const", "trend","none", "both"),
+                   lag = 1:2L, 
+                   thDelay = 0:1L, 
+                   test = c("1vs", "2vs3")) %>% 
+   filter(thDelay<lag)
> 
> 
> ### run ###
> res <- grid %>% 
+   mutate(dat = pmap(list(include, lag, thDelay, test),
+                     ~setarTest(IIPUs[1:100], 
+                                include= ..1,
+                                m = ..2,
+                                thDelay = ..3,
+                                test = ..4,
+                                nboot = 2,
+                                seed = 4323)))
> 
> 
> ### show F tests ###
> res %>% 
+   mutate(Ftests = map(dat, ~enframe(.$Ftests))) %>% 
+   select(-dat) %>% 
+   unnest(Ftests)%>% 
+   as.data.frame() %>% 
+   head(10) %>% 
+   print(digits=3) 
   include lag thDelay test name value
1     both   1       0  1vs 1vs2  8.22
2     both   1       0  1vs 1vs3 16.70
3     both   1       0  1vs 2vs3  7.82
4     both   1       0 2vs3 1vs2  8.22
5     both   1       0 2vs3 1vs3 16.70
6     both   1       0 2vs3 2vs3  7.82
7     both   2       0  1vs 1vs2 10.86
8     both   2       0  1vs 1vs3 26.08
9     both   2       0  1vs 2vs3 13.70
10    both   2       0 2vs3 1vs2 10.86
> 
> res %>% 
+   mutate(Ftests = map(dat, ~enframe(.$SSRs))) %>% 
+   select(-dat) %>% 
+   unnest(Ftests)%>% 
+   as.data.frame() %>% 
+   head(10) %>% 
+   print(digits=3) 
   include lag thDelay test name value
1     both   1       0  1vs    1 113.9
2     both   1       0  1vs    2 105.2
3     both   1       0  1vs    3  97.5
4     both   1       0 2vs3    1 113.9
5     both   1       0 2vs3    2 105.2
6     both   1       0 2vs3    3  97.5
7     both   2       0  1vs    1 109.6
8     both   2       0  1vs    2  98.6
9     both   2       0  1vs    3  86.5
10    both   2       0 2vs3    1 109.6
> 
> 
> proc.time()
   user  system elapsed 
    4.5     0.4     4.9