@@ -112,13 +112,17 @@ boot_ur <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_l
112112 }
113113
114114 spec <- list (" bootstrap" = bootstrap , " B" = B , " block_length" = inputs $ inputs $ l ,
115- " ar_AWB" = inputs $ inputs $ ar_AWB , " level" = level , " union" = union , " union_quantile" = union_quantile ,
116- " deterministics" = deterministics , " detrend" = detrend , " min_lag" = min_lag ,
117- " max_lag" = inputs $ inputs $ p_max , " criterion" = criterion , " criterion_scale" = criterion_scale )
118-
115+ " ar_AWB" = inputs $ inputs $ ar_AWB , " level" = level ,
116+ " union" = union , " union_quantile" = inputs $ inputs $ union_quantile ,
117+ " deterministics" = inputs $ inputs $ deterministics ,
118+ " detrend" = inputs $ inputs $ detrend , " min_lag" = min_lag ,
119+ " max_lag" = inputs $ inputs $ p_max , " criterion" = inputs $ inputs $ criterion ,
120+ " criterion_scale" = inputs $ inputs $ criterion_scale )
121+
119122 # Results
120123 if (union ) { # Union test
121- iADFout <- iADF_cpp(test_i = inputs $ test_stats , t_star = inputs $ test_stats_star , level = inputs $ level )
124+ iADFout <- iADF_cpp(test_i = inputs $ test_stats , t_star = inputs $ test_stats_star ,
125+ level = inputs $ level )
122126 iADFout <- cbind(rep(NA , nrow(iADFout )), iADFout )
123127 if (NCOL(data ) > 1 ) {
124128 rownames(iADFout ) <- var_names
@@ -133,13 +137,6 @@ boot_ur <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_l
133137 rownames(iADFout ) <- var_names
134138 colnames(iADFout ) <- c(" gamma" , " statistic" , " p.value" )
135139 }
136- switch (deterministics ,
137- " trend" = deterministics <- " intercept and trend" ,
138- " intercept" = deterministics <- " intercept" ,
139- " none" = deterministics <- " no deterministics" )
140- switch (detrend ,
141- " OLS" = detrend <- " ADF" ,
142- " QD" = detrend <- " ADF-QD" )
143140 }
144141
145142 if (! is.null(level )) {
@@ -148,12 +145,13 @@ boot_ur <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_l
148145 rej_H0 <- NULL
149146 }
150147
151-
152148 if (NCOL(data ) > 1 ) {
153- if (union ){
149+ if (union ) {
154150 method_name <- paste(bootstrap , " Bootstrap Union test on each individual series (no multiple testing correction)" )
155- }else {
156- method_name <- paste(bootstrap , " Bootstrap" , detrend , " test ( with" , deterministics ," ) on each individual series (no multiple testing correction)" )
151+ } else {
152+ method_name <- paste(bootstrap , " Bootstrap" , inputs $ inputs $ name ,
153+ " test ( with" , inputs $ inputs $ deterministics ,
154+ " ) on each individual series (no multiple testing correction)" )
157155 }
158156 boot_ur_output <- list (method = method_name , data.name = data_name ,
159157 null.value = c(" gamma" = 0 ), alternative = " less" ,
@@ -170,15 +168,18 @@ boot_ur <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_l
170168 attr(iADFtstat , " names" ) <- " tstat"
171169 p_val <- drop(iADFout [1 , 3 ])
172170 attr(p_val , " names" ) <- " p-value"
173-
174- if (union ){
171+
172+ if (union ) {
175173 method_name <- paste(bootstrap , " Bootstrap Union test on a single time series" )
176- }else {
177- method_name <- paste(bootstrap , " Bootstrap" , detrend , " test ( with" , deterministics ," ) on a single time series" )
174+ } else {
175+ method_name <- paste(bootstrap , " Bootstrap" , inputs $ inputs $ detrend ,
176+ " test ( with" , inputs $ inputs $ deterministics ,
177+ " ) on a single time series" )
178178 }
179179 boot_ur_output <- list (method = method_name , data.name = var_names ,
180180 null.value = c(" gamma" = 0 ), alternative = " less" ,
181- estimate = param , statistic = iADFtstat , p.value = p_val , specifications = spec )
181+ estimate = param , statistic = iADFtstat , p.value = p_val ,
182+ specifications = spec )
182183 class(boot_ur_output ) <- c(" bootUR" , " htest" )
183184 }
184185
@@ -421,9 +422,11 @@ boot_fdr <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_
421422 }
422423
423424 spec <- list (" bootstrap" = bootstrap , " B" = B , " block_length" = inputs $ inputs $ l ,
424- " ar_AWB" = inputs $ inputs $ ar_AWB , " FDR_level" = FDR_level , " union" = union , " deterministics" = deterministics ,
425- " detrend" = detrend , " min_lag" = min_lag , " max_lag" = inputs $ inputs $ p_max , " criterion" = criterion ,
426- " criterion_scale" = criterion_scale )
425+ " ar_AWB" = inputs $ inputs $ ar_AWB , " FDR_level" = FDR_level , " union" = union ,
426+ " deterministics" = inputs $ inputs $ deterministics ,
427+ " detrend" = inputs $ inputs $ detrend , " min_lag" = min_lag ,
428+ " max_lag" = inputs $ inputs $ p_max , " criterion" = inputs $ inputs $ criterion ,
429+ " criterion_scale" = inputs $ inputs $ criterion_scale )
427430
428431 if (union ) { # Union Tests
429432 bFDRout <- FDR_cpp(test_i = inputs $ test_stats , t_star = inputs $ test_stats_star ,
@@ -436,14 +439,8 @@ boot_fdr <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_
436439 t_star = inputs $ t_star [ , 1 ,], level = inputs $ level )
437440 estimates <- t(inputs $ param_i )
438441 tstats <- drop(inputs $ tests_i [1 , ])
439- switch (deterministics ,
440- " trend" = deterministics <- " intercept and trend" ,
441- " intercept" = deterministics <- " intercept" ,
442- " none" = deterministics <- " no deterministics" )
443- switch (detrend ,
444- " OLS" = detrend <- " ADF" ,
445- " QD" = detrend <- " ADF-QD" )
446- method_name <- paste(bootstrap , " Bootstrap" , detrend , " tests ( with" , deterministics ," ) with False Discovery Rate control" )
442+ method_name <- paste(bootstrap , " Bootstrap" , inputs $ inputs $ name , " tests ( with" ,
443+ inputs $ inputs $ deterministics , " ) with False Discovery Rate control" )
447444 }
448445 rej_H0 <- matrix (bFDRout $ rej_H0 == 1 , nrow = NCOL(data ))
449446 rownames(rej_H0 ) <- var_names
@@ -457,7 +454,8 @@ boot_fdr <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999, block_
457454 fdr_output <- list (method = method_name , data.name = data_name ,
458455 null.value = c(" gamma" = 0 ), alternative = " less" ,
459456 estimate = estimates , statistic = tstats , p.value = p_vals ,
460- rejections = rej_H0 , details = FDR_seq , series.names = var_names , specifications = spec )
457+ rejections = rej_H0 , details = FDR_seq , series.names = var_names ,
458+ specifications = spec )
461459 class(fdr_output ) <- c(" bootUR" , " mult_htest" )
462460
463461 return (fdr_output )
@@ -549,10 +547,12 @@ boot_sqt <- function(data, data_name = NULL, steps = 0:NCOL(data), bootstrap = "
549547 }
550548
551549 spec <- list (" steps" = steps , " bootstrap" = bootstrap , " B" = B , " block_length" = inputs $ inputs $ l ,
552- " ar_AWB" = inputs $ inputs $ ar_AWB , " SQT_level" = SQT_level , " union" = union , " deterministics" = deterministics ,
553- " detrend" = detrend , " min_lag" = min_lag , " max_lag" = inputs $ inputs $ p_max , " criterion" = criterion ,
554- " criterion_scale" = criterion_scale )
555-
550+ " ar_AWB" = inputs $ inputs $ ar_AWB , " SQT_level" = SQT_level , " union" = union ,
551+ " deterministics" = inputs $ inputs $ deterministics ,
552+ " detrend" = inputs $ inputs $ detrend , " min_lag" = min_lag ,
553+ " max_lag" = inputs $ inputs $ p_max , " criterion" = inputs $ inputs $ criterion ,
554+ " criterion_scale" = inputs $ inputs $ criterion_scale )
555+
556556 if (union ) { # Union Tests
557557 BSQTout <- BSQT_cpp(pvec = inputs $ p_vec , test_i = inputs $ test_stats ,
558558 t_star = inputs $ test_stats_star , level = inputs $ level )
@@ -564,15 +564,10 @@ boot_sqt <- function(data, data_name = NULL, steps = 0:NCOL(data), bootstrap = "
564564 t_star = inputs $ t_star [ , 1 ,], level = inputs $ level )
565565 estimates <- t(inputs $ param_i )
566566 tstats <- drop(inputs $ tests_i [1 , ])
567- switch (deterministics ,
568- " trend" = deterministics <- " intercept and trend" ,
569- " intercept" = deterministics <- " intercept" ,
570- " none" = deterministics <- " no deterministics" )
571- switch (detrend ,
572- " OLS" = detrend <- " ADF" ,
573- " QD" = detrend <- " ADF-QD" )
574- method_name <- paste(bootstrap , " Bootstrap Sequential Quantile" , detrend , " test ( with" , deterministics ," )" )
575-
567+ method_name <- paste(bootstrap , " Bootstrap Sequential Quantile" ,
568+ inputs $ inputs $ name , " test ( with" ,
569+ inputs $ inputs $ deterministics ," )" )
570+
576571 }
577572 rej_H0 <- matrix (BSQTout $ rej_H0 == 1 , nrow = NCOL(data ))
578573 rownames(rej_H0 ) <- var_names
@@ -586,7 +581,8 @@ boot_sqt <- function(data, data_name = NULL, steps = 0:NCOL(data), bootstrap = "
586581 sqt_output <- list (method = method_name , data.name = data_name ,
587582 null.value = c(" gamma" = 0 ), alternative = " less" ,
588583 estimate = estimates , statistic = tstats , p.value = p_vals ,
589- rejections = rej_H0 , details = BSQT_seq , series.names = var_names , specifications = spec )
584+ rejections = rej_H0 , details = BSQT_seq , series.names = var_names ,
585+ specifications = spec )
590586 class(sqt_output ) <- c(" bootUR" , " mult_htest" )
591587 return (sqt_output )
592588}
@@ -654,12 +650,15 @@ boot_panel <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999,
654650 if (is.null(data_name )) {
655651 data_name <- deparse(substitute(data ))
656652 }
657-
653+
658654 spec <- list (" bootstrap" = bootstrap , " B" = B , " block_length" = inputs $ inputs $ l ,
659- " ar_AWB" = inputs $ inputs $ ar_AWB ," union" = union , " union_quantile" = union_quantile ,
660- " deterministics" = deterministics , " detrend" = detrend , " min_lag" = min_lag ,
661- " max_lag" = inputs $ inputs $ p_max , " criterion" = criterion , " criterion_scale" = criterion_scale )
662-
655+ " ar_AWB" = inputs $ inputs $ ar_AWB ," union" = union ,
656+ " union_quantile" = inputs $ inputs $ union_quantile ,
657+ " deterministics" = inputs $ inputs $ deterministics ,
658+ " detrend" = inputs $ inputs $ detrend , " min_lag" = min_lag ,
659+ " max_lag" = inputs $ inputs $ p_max , " criterion" = inputs $ inputs $ criterion ,
660+ " criterion_scale" = inputs $ inputs $ criterion_scale )
661+
663662 if (union ) { # Union Test
664663 GM_test <- mean(inputs $ test_stats )
665664 t_star <- rowMeans(inputs $ test_stats_star )
@@ -669,14 +668,8 @@ boot_panel <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999,
669668 GM_test <- rowMeans(inputs $ tests_i )
670669 t_star <- apply(inputs $ t_star , 1 : 2 , mean )
671670 p_val <- sapply(1 , function (i ){mean(t_star [, i ] < GM_test [i ])})
672- switch (deterministics ,
673- " trend" = deterministics <- " intercept and trend" ,
674- " intercept" = deterministics <- " intercept" ,
675- " none" = deterministics <- " no deterministics" )
676- switch (detrend ,
677- " OLS" = detrend <- " ADF" ,
678- " QD" = detrend <- " ADF-QD" )
679- method_name <- paste(" Panel" , bootstrap , " Bootstrap Group-Mean" , detrend , " test ( with" , deterministics ," )" )
671+ method_name <- paste(" Panel" , bootstrap , " Bootstrap Group-Mean" , inputs $ inputs $ name ,
672+ " test ( with" , inputs $ inputs $ deterministics ," )" )
680673 }
681674
682675 attr(GM_test , " names" ) <- " tstat"
@@ -685,7 +678,8 @@ boot_panel <- function(data, data_name = NULL, bootstrap = "AWB", B = 1999,
685678 attr(p_val , " names" ) <- " p-value"
686679 panel_output <- list (method = method_name , data.name = data_name ,
687680 null.value = c(" gamma" = 0 ), alternative = " less" ,
688- estimate = gamma_hat , statistic = GM_test , p.value = p_val , specifications = spec )
681+ estimate = gamma_hat , statistic = GM_test , p.value = p_val ,
682+ specifications = spec )
689683 class(panel_output ) <- c(" bootUR" , " htest" )
690684 return (panel_output )
691685}
0 commit comments