tsbootstrap: Bootstrap for General Stationary Data

View source: R/tsutils.R

tsbootstrapR Documentation

Bootstrap for General Stationary Data


tsbootstrap generates bootstrap samples for general stationary data and computes the bootstrap estimate of standard error and bias if a statistic is given.


tsbootstrap(x, nb = 1, statistic = NULL, m = 1, b = NULL,
            type = c("stationary","block"), ...)



a numeric vector or time series giving the original data.


the number of bootstrap series to compute.


a function which when applied to a time series returns a vector containing the statistic(s) of interest.


the length of the basic blocks in the block of blocks bootstrap.


if type is "stationary", then b is the mean block length. If type is "block", then b is the fixed block length.


the type of bootstrap to generate the simulated time series. The possible input values are "stationary" (stationary bootstrap with mean block length b) and "block" (blockwise bootstrap with block length b). Default to "stationary".


additional arguments for statistic which are passed unchanged each time statistic is called.


If type is "stationary", then the stationary bootstrap scheme with mean block length b according to Politis and Romano (1994) is computed. For type equals "block", the blockwise bootstrap with block length b according to Kuensch (1989) is used.

If m > 1, then the block of blocks bootstrap is computed (see Kuensch, 1989). The basic sampling scheme is the same as for the case m = 1, except that the bootstrap is applied to a series y containing blocks of length m, where each block of y is defined as y[t] = (x[t], …, x[t-m+1]). Therefore, for the block of blocks bootstrap the first argument of statistic is given by a n x m matrix yb, where each row of yb contains one bootstrapped basic block observation y[t] (n is the number of observations in x).

Note, that for statistics which are functions of the empirical m-dimensional marginal (m > 1) only this procedure yields asymptotically valid bootstrap estimates. The case m = 1 may only be used for symmetric statistics (i.e., for statistics which are invariant under permutations of x). tsboot does not implement the block of blocks bootstrap, and, therefore, the first example in tsboot yields inconsistent estimates.

For consistency, the (mean) block length b should grow with n at an appropriate rate. If b is not given, then a default growth rate of const * n^(1/3) is used. This rate is "optimal" under certain conditions (see the references for more details). However, in general the growth rate depends on the specific properties of the data generation process. A default value for const has been determined by a Monte Carlo simulation using a Gaussian AR(1) process (AR(1)-parameter of 0.5, 500 observations). const has been chosen such that the mean square error for the bootstrap estimate of the variance of the empirical mean is minimized.

Note, that the computationally intensive parts are fully implemented in C which makes tsbootstrap about 10 to 30 times faster than tsboot.

Missing values are not allowed.

There is a special print method for objects of class "resample.statistic" which by default uses max(3, getOption("digits") - 3) digits to format real numbers.


If statistic is NULL, then it returns a matrix or time series with nb columns and length(x) rows containing the bootstrap data. Each column contains one bootstrap sample.

If statistic is given, then a list of class "resample.statistic" with the following elements is returned:


the results of applying statistic to each of the simulated time series.


the results of applying statistic to the original series.


the bootstrap estimate of the bias of statistic.


the bootstrap estimate of the standard error of statistic.


the original call of tsbootstrap.


A. Trapletti


H. R. Kuensch (1989): The Jackknife and the Bootstrap for General Stationary Observations. The Annals of Statistics 17, 1217–1241.

D. N. Politis and J. P. Romano (1994): The Stationary Bootstrap. Journal of the American Statistical Association 89, 1303–1313.

See Also

sample, surrogate, tsboot


n <- 500  # Generate AR(1) process
a <- 0.6
e <- rnorm(n+100)  
x <- double(n+100)
x[1] <- rnorm(1)
for(i in 2:(n+100)) {
  x[i] <- a * x[i-1] + e[i]
x <- ts(x[-(1:100)])

tsbootstrap(x, nb=500, statistic=mean)

# Asymptotic formula for the std. error of the mean

acflag1 <- function(x)
  xo <- c(x[,1], x[1,2])
  xm <- mean(xo)

tsbootstrap(x, nb=500, statistic=acflag1, m=2)

# Asymptotic formula for the std. error of the acf at lag one

tseries documentation built on May 1, 2022, 5:08 p.m.

Related to tsbootstrap in tseries...