arch.bootstrap.SPA

class arch.bootstrap.SPA(benchmark: ndarray | DataFrame | Series, models: ndarray | DataFrame | Series, block_size: int | None = None, reps: int = 1000, bootstrap: 'stationary' | 'sb' | 'circular' | 'cbb' | 'moving block' | 'mbb' = 'stationary', studentize: bool = True, nested: bool = False, *, seed: int | Generator | RandomState | None = None)[source]

Test of Superior Predictive Ability (SPA) of White and Hansen.

The SPA is also known as the Reality Check or Bootstrap Data Snooper.

Parameters:
benchmark: ndarray | DataFrame | Series

T element array of benchmark model losses. There must be at least three observations, and the losses must be finite.

models: ndarray | DataFrame | Series

T by k element array of alternative model losses, with the same T as benchmark and k at least 1.

block_size: int | None = None

Length of window to use in the bootstrap, between 1 and T. If not provided, sqrt(T) is used. In general, this should be provided and chosen to be appropriate for the data.

reps: int = 1000

Number of bootstrap replications to use. Must be at least 1.

bootstrap: 'stationary' | 'sb' | 'circular' | 'cbb' | 'moving block' | 'mbb' = 'stationary'

Bootstrap to use. Not case sensitive. Options are

  • ”stationary” or “sb”: Stationary bootstrap

  • ”circular” or “cbb”: Circular block bootstrap

  • ”moving block” or “mbb”: Moving block bootstrap

studentize: bool = True

Flag indicating to studentize loss differentials. Studentization is also applied inside each bootstrap replication, see Notes. If False, the loss differentials are not studentized in the original data or in the bootstrap replications.

nested: bool = False

Flag indicating to use a nested bootstrap to compute the variances used to studentize, instead of the kernel estimator of the long-run variance that matches the bootstrap. The variances are computed in the original data and in each bootstrap replication, so the procedure uses reps squared resamples and can be very slow. Can only be True when studentize is True.

seed: int | Generator | RandomState | None = None

Seed value to use when creating the bootstrap used in the comparison. If an integer or None, the NumPy default_rng is used with the seed value. If a Generator or a RandomState, the argument is used.

Raises:
  • TypeError – If reps or block_size is not an integer, studentize or nested is not a bool, seed is not an integer, a Generator, a RandomState or None, bootstrap is not a string, or the losses cannot be converted to float64.

  • ValueError – If benchmark is not 1-d, models is not 2-d with T rows, there are fewer than three observations, the losses contain NaN or inf, reps is less than 1, block_size is not between 1 and T, seed is negative, nested is True and studentize is False, or bootstrap is not one of the allowed values.

See also

arch.bootstrap.StepM

StepM multiple comparison procedure of Romano and Wolf.

Notes

The three p-value correspond to different re-centering decisions.
  • Upper : Never recenter to all models are relevant to distribution

  • Consistent : Only recenter if closer than a log(log(t)) bound

  • Lower : Never recenter a model if worse than benchmark

When studentize is True, the statistic for each model is the average loss differential divided by an estimate of its standard error. The standard error is also estimated in each bootstrap replication, using the bootstrap sample, and used to studentize the re-centered average of the bootstrap sample [3]. Studentizing inside the bootstrap makes the bootstrap distribution reflect the sampling variation in the estimated standard errors that is present in the statistic from the original data. If the loss differential of a model is constant in a bootstrap sample, which can occur when the model differs from the benchmark in very few periods, the standard error from the original data is used for that model in that replication.

If nested is False, the standard errors are the square root of a kernel estimator of the long-run variance divided by T. The kernel is chosen to match the bootstrap, so that the estimator is the variance of the sample mean that is implied by the bootstrap, using the average block size as the bandwidth.

  • Stationary bootstrap : The lag \(i\) autocovariance has weight \((1-i/T)(1-p)^i + (i/T)(1-p)^{T-i}\) where \(p\) is the inverse of the block size [4].

  • Circular block bootstrap : The Bartlett kernel applied to the circular autocovariances.

  • Moving block bootstrap : The Bartlett kernel.

If nested is True, the kernel is not used. The variance is instead the variance of the sample mean across reps replications of a bootstrap of the data, which is a bootstrap of the original loss differentials in the original data and a bootstrap of the bootstrap sample in each replication.

The same variances are used to select the models that are re-centered when computing the consistent p-value, even if studentize is False. No other studentization is done when studentize is False.

If the loss differential of a model is constant in the original data, for example because the model is identical to the benchmark, its variance is 0 and its test statistic is not meaningful. A RuntimeWarning is issued when the test is created, and such models should be removed.

See [1] and [2] for details.

References

Methods

better_models([pvalue, pvalue_type])

Return the set of models rejected as being equal-or-worse than the benchmark.

compute()

Compute the bootstrap pvalue.

critical_values([pvalue])

Return data-dependent critical values.

reset()

Reset the bootstrap to its initial state.

subset(selector)

Set the active models to run the SPA on.

Properties

bootstrap

The bootstrap used in the comparison.

pvalues

The lower, consistent and upper p-values.