qis.bootstrap_ar_process

qis.bootstrap_ar_process(data, bootstrap_type=BootstrapType.STATIONARY, bootstrap_output=BootstrapOutput.DF_TO_LIST_ARRAYS, num_samples=10, index_length=1000, block_size=30, min_block_size=1, seed=1, bootstrapped_indices=None, is_positive=True)[source]

resample the residuals of a fitted AR(1) per column and rerun the recursion.

For persistent level series, such as valuation ratios, resampling observations would break the persistence; resampling innovations keeps it. Each column is fitted with compute_ar_residuals() on complete lag pairs, indices are drawn over the residual rows, and every path starts from the column means of all observed data, y0 = nanmean, and runs y_t = intercept + beta * y_{t-1} + residual_{J_t}, a whole residual row per step so contemporaneous innovations stay paired. The start value is not part of the output, so row t of a path has applied the innovations drawn at index rows 0..t. The paths are alternative histories around the fitted mean, not forecasts from the last observation.

Positivity rule: with is_positive=True a column is constrained when all its observed values are strictly positive. After every step a non-positive value of such a column is replaced by the 25% quantile, with linear interpolation, of that column’s observed values (a positive number), and the replaced value feeds the next step. Each column uses its own floor, so columns stay independent. A column with a zero or negative observation is never constrained, since positivity is not a property of its data.

Parameters:
  • data (Series | DataFrame) – observations, one column per series; rows must be complete across columns

  • bootstrap_type (BootstrapType) – resampling scheme; see BootstrapType

  • bootstrap_output (BootstrapOutput) – shape of the result; see BootstrapOutput. SERIES_TO_DF needs a Series

  • num_samples (int) – number of independent draws

  • index_length (int) – length of each path

  • block_size (int) – mean block length for STATIONARY, exact length for FIXED_BLOCK

  • min_block_size (int) – floor on the drawn block length under STATIONARY

  • seed (int) – seed for the numba random state

  • bootstrapped_indices (ndarray) – precomputed indices over the residual rows, which override the sampling arguments

  • is_positive (bool) – apply the positivity rule above; False leaves every column unconstrained

Returns:

a DataFrame of paths for SERIES_TO_DF, with columns path_1, path_2, … on a RangeIndex, or a numba list of arrays of shape (index_length, number of columns) for DF_TO_LIST_ARRAYS

Raises:

ValueError – if the AR(1) is not identified (see compute_ar_residuals()), if supplied bootstrapped_indices fall outside the residual rows, or if SERIES_TO_DF is requested for a DataFrame

Return type:

List | DataFrame