hhj {blocklength}  R Documentation 
Hall, Horowitz, and Jing (1995) "HHJ" Algorithm to Select the Optimal BlockLength
Description
Perform the Hall, Horowitz, and Jing (1995) "HHJ" crossvalidation algorithm to select the optimal blocklength for a bootstrap on dependent data (blockbootstrap). Dependent data such as stationary time series are suitable for usage with the HHJ algorithm.
Usage
hhj(
series,
nb = 100L,
n_iter = 10L,
pilot_block_length = NULL,
sub_sample = NULL,
k = "twosided",
bofb = 1L,
search_grid = NULL,
grid_step = c(1L, 1L),
cl = NULL,
verbose = TRUE,
plots = TRUE
)
Arguments
series 
a numeric vector or time series giving the original data for which to find the optimal blocklength for. 
nb 
an integer value, number of bootstrapped series to compute. 
n_iter 
an integer value, maximum number of iterations for the HHJ algorithm to compute. 
pilot_block_length 
a numeric value, the blocklength ( 
sub_sample 
a numeric value, the length of each overlapping
subsample, 
k 
a character string, either 
bofb 
a numeric value, length of the basic blocks in the
blockofblocks bootstrap, see 
search_grid 
a numeric value, the range of solutions around 
grid_step 
a numeric value or vector of at most length 2, the number of
steps to increment over the subsample blocklengths when evaluating the

cl 
a cluster object, created by package parallel,
doParallel, or snow. If 
verbose 
a logical value, if set to 
plots 
a logical value, if set to 
Details
The HHJ algorithm is computationally intensive as it relies on a
crossvalidation process using a type of subsampling to estimate the mean
squared error (MSE
) incurred by the bootstrap at various blocklengths.
Underthehood, hhj()
makes use of tsbootstrap
,
see Trapletti and Hornik (2020), to perform the moving blockbootstrap
(or the blockofblocks bootstrap by setting bofb > 1
) according
to Kunsch (1989).
Value
an object of class 'hhj'
References
Adrian Trapletti and Kurt Hornik (2020). tseries: Time Series Analysis and Computational Finance. R package version 0.1048.
Kunsch, H. (1989) The Jackknife and the Bootstrap for General Stationary Observations. The Annals of Statistics, 17(3), 12171241. Retrieved February 16, 2021, from http://www.jstor.org/stable/2241719
Peter Hall, Joel L. Horowitz, BingYi Jing, On blocking rules for the bootstrap with dependent data, Biometrika, Volume 82, Issue 3, September 1995, Pages 561574, DOI: doi: 10.1093/biomet/82.3.561
Examples
# Generate AR(1) time series
sim < stats::arima.sim(list(order = c(1, 0, 0), ar = 0.5),
n = 500, innov = rnorm(500))
# Calculate optimal block length for series
hhj(sim, sub_sample = 10)
# Use parallel computing
library(parallel)
# Make cluster object with 2 cores
cl < makeCluster(2)
# Calculate optimal block length for series
hhj(sim, cl = cl)