dsrboot: Data Shape Replication Bootstrap

View source: R/dsrboot.R

dsrbootR Documentation

Data Shape Replication Bootstrap

Description

The function implements a bootstrap inspired by the Maximum Entropy Bootstrap

Usage

dsrboot(y, nsim = 100, intermittent = FALSE, type = c("multiplicative",
  "additive"), kind = c("nonparametric", "parametric"), lag = frequency(y),
  sd = NULL, scale = TRUE)

## S3 method for class 'dsrboot'
plot(x, sorted = FALSE, legend = TRUE, ...)

Arguments

y

The original time series

nsim

Number of iterations (simulations) to run.

intermittent

Whether to treat the demand as intermittent or not.

type

Type of bootstrap to use. "additive" means that the randomness is added, while "multiplicative" implies the multiplication.

kind

A kind of the bootstrap to do: nonparametric or parametric. The latter relies on the normal distribution, while the former uses the empirical distribution of differences of the data.

lag

The lag to use in the calculation of differences. Should be 1 for non-seasonal data.

sd

Standard deviation to use in the normal distribution. Estimated as mean absolute differences of the data if omitted.

scale

Whether or not to do scaling of time series to the bootstrapped ones to have similar variance to the original data.

x

The object of the class dsrboot.

sorted

Whether the sorted (TRUE) or the original (FALSE) data should be used.

legend

Whether to produce the legend on the plot.

...

Other parameters passed to the plot function.

Details

The "Data Shape Replication" bootstrap reproduces the shape of the original time series by creating randomness around it. It is done in the following steps:

1. Sort the data in the ascending order, recording the original order of elements; 2. Take first differences of the original data and sort them; 3. Generate random numbers from the uniform distribution between 0 and 1; 4. Get the smoothed differences that correspond to the random numbers (randomly extract empirical quantiles). This way we take the empirical density into account when selecting the differences; 5. Add the random differences to the sorted series from (1) to get a new time series; 6. Sort the new time series in the ascending order; 7. Reorder (6) based on the initial order of series; 8. Centre the data around the original series; 9. Scale the data to make sure that the variance is constant over time.

If the multiplicative bootstrap is used then logarithms of the sorted series are used and at the very end, the exponent of the resulting data is taken. This way the discrepancies in the data have similar scale no matter what the level of the original series is. In case of the additive bootstrap, the trended series will be noisier when the level of series is low.

Value

The function returns:

  • call - the call that was used originally;

  • data - the original data used in the function;

  • boot - the matrix with the new series in columns and observations in rows.

  • type - type of the bootstrap used.

  • sd - the value of sd used in case of parameteric bootstrap.

  • scale - whether the scaling was needed.

  • smooth - the smoothed ordered actual data.

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

References

Vinod HD, López-de-Lacalle J (2009). "Maximum Entropy Bootstrap for Time Series: The meboot R Package." Journal of Statistical Software, 29(5), 1–19. \Sexpr[results=rd]{tools:::Rd_expr_doi("doi:10.18637/jss.v029.i05")}.

Examples

dsrboot(AirPassengers) |> plot()


config-i1/greybox documentation built on Dec. 12, 2024, 1:42 p.m.