Bootstrap

open class Bootstrap(originalData: DoubleArray, val estimator: BSEstimatorIfc = BSEstimatorIfc.Average(), stream: RNStreamIfc = KSLRandom.nextRNStream(), name: String? = null) : IdentityIfc, RNStreamControlIfc, RNStreamChangeIfc, BootstrapEstimateIfc

A class to do statistical bootstrapping. The calculations occur via the method generateSamples(). Until generateSamples() is called the results are meaningless.

It is possible to save the individual bootstrap samples from which the bootstrap samples can be retrieved. Recognize that this could be a lot of data. The class implements four classic bootstrap confidence intervals normal, basic, percentile, and BCa. To estimate the quantiles it uses algorithm 8 from Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician 50, 361–365 as the default. This can be changed by the user.

Parameters

originalData

the data to sample from to form the bootstraps

estimator

a function to be applied to the data

stream

the random number stream for forming the bootstraps

name

a name for the bootstrap statistics

Constructors

Link copied to clipboard
constructor(originalData: DoubleArray, estimator: BSEstimatorIfc = BSEstimatorIfc.Average(), stream: RNStreamIfc = KSLRandom.nextRNStream(), name: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

This is the statistics of the bootstrap replicates.

Link copied to clipboard

If true, the stream will automatically participate in having its stream advanced to the next sub-stream via stream managers

Link copied to clipboard
open override var antithetic: Boolean

Tells the stream to start producing antithetic variates

Link copied to clipboard

This is acrossBootstrapAverage - originalDataEstimate

Link copied to clipboard

Each element is the bootstrap estimate for sample i minus originalDataEstimate

Link copied to clipboard
open override val bootstrapEstimates: DoubleArray

These are the bootstrap replicates.

Link copied to clipboard

If the bootstrap samples were saved, this returns the generated averages for each of the samples

Link copied to clipboard

If the bootstrap samples were saved, this returns the generated variance for each of the samples

Link copied to clipboard

This is the standard deviation of the across bootstrap observations of the estimator for each bootstrap generated

Link copied to clipboard

If the save bootstrap data option was not turned on during the sampling then the list returned is empty.

Link copied to clipboard
open override var defaultCILevel: Double

the default confidence interval level

Link copied to clipboard
Link copied to clipboard
open override val id: Int
Link copied to clipboard
open override var label: String?
Link copied to clipboard
open override val name: String
Link copied to clipboard

The number of bootstrap samples that were used to produce the bootstrap estimate

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

the average for the original data

Link copied to clipboard
open override var originalDataEstimate: Double
Link copied to clipboard
open override val originalDataSampleSize: Int

The size of the original population of data from which to sample

Link copied to clipboard
open override var resetStartStreamOption: Boolean

If true, the stream will automatically participate in having its stream reset to its start stream via stream managers

Link copied to clipboard
open override var rnStream: RNStreamIfc

the underlying stream of random numbers

Link copied to clipboard

Each element is the bootstrap estimate for sample i minus getOriginalDataEstimate() divided by getBootstrapStdErrEstimate()

Link copied to clipboard

The list itself is unmodifiable. The underlying statistic objects can be modified, but have no effect on the bootstrap generate statistics. The statistical values will be changed the next time generateSamples() is executed. Users are advised to copy the statistics in the list (via Statistic newInstance()) before executing generateSamples if persistence is required.

Link copied to clipboard
open val streamNumber: Int

Functions

Link copied to clipboard

For the so called, BCa, interval, the approach requires an acceleration factor. The acceleration factor measures the rate of change of the standard error of the estimator with respect to the target parameter on a normalized scale. This function computes the acceleration factor based on the bootstrap estimates and the original estimated quantity using jackknifing.

Link copied to clipboard
open override fun advanceToNextSubStream()

Positions the RNG at the beginning of its next sub-stream

Link copied to clipboard
open fun asString(): String
Link copied to clipboard
open fun basicBootstrapCI(level: Double = defaultCILevel): Interval

The "basic" method, but with no bias correction. This is the so-called centered percentile method (2θ − Bu , 2θ − Bl ) where θ is the bootstrap estimator and Bu is the 1 - alpha/2 percentile and Bl is the lower (alpha/2) percentile, where level = 1-alpha of the bootstrap replicates.

Link copied to clipboard
fun bcaBootstrapCI(level: Double = defaultCILevel): Interval

The BCa bootstrap confidence interval which accounts for bias correction and adjusted for acceleration.

Link copied to clipboard

For the so called, BCa, interval, the approach requires a bias correction factor which in essence measures the median bias of the bootstrap replicates for the estimated quantity. This function computes the bias correction factor based on the bootstrap estimates and the original estimated quantity.

Link copied to clipboard
fun bootstrapTCI(level: Double = defaultCILevel): Interval

This is the bootstrap-t or sometimes called percentile-t confidence interval. It is formed by capturing a t-type statistic which standardizes the individual bootstrap estimates. This confidence interval is only available if the parameter (numBootstrapTSamples) in the generateSamples() function is greater than 1; otherwise, the returned interval is (-infinity, +infinity).

Link copied to clipboard
Link copied to clipboard

Creates a random variable to represent the data in each bootstrap sample for which the data was saved.

Link copied to clipboard
fun generateSamples(numBootstrapSamples: Int, saveBootstrapSamples: Boolean = false, numBootstrapTSamples: Int = 0)

This method changes the underlying state of the Bootstrap instance by performing the bootstrap sampling.

Link copied to clipboard
open fun percentileBootstrapCI(level: Double = defaultCILevel): Interval

The "percentile" method, but with no bias correction. This is the percentile method (Bl , Bu ) where Bu is the 1 - alpha/2 percentile and Bl is the lower (alpha/2) percentile, where level = 1-alpha of the bootstrap replicates

Link copied to clipboard
open override fun resetStartStream()

The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.

Link copied to clipboard
open override fun resetStartSubStream()

Resets the position of the RNG at the start of the current sub-stream

Link copied to clipboard
open fun stdNormalBootstrapCI(level: Double = defaultCILevel): Interval

Gets the standard normal based bootstrap confidence interval. Not recommended.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open fun useStreamNumber(streamNumber: Int)

Assigns the stream associated with the supplied number from the default RNStreamProvider