Java Statistical Classes

jsc.tests
Class BootstrapTest

java.lang.Object
  |
  +--jsc.tests.BootstrapTest
All Implemented Interfaces:
SignificanceTest
Direct Known Subclasses:
TwoSampleBootstrapTest

public abstract class BootstrapTest
extends Object
implements SignificanceTest

Root class for bootstrap significance tests. See Efron and Tibshirani (1993, Ch.16). Subclasses must provide method bootstrapSample() to generate random bootstrap samples, and a constructor that sets up the appropriate data from which the samples are drawn.

Method calculateSP() calculates the significance probability of the bootstrap test. That is, it calculates the statistic for bootstrap samples drawn in some way from the original data, and calculates the proportion of these that are less than or equal to t (Tail.LOWER), greater than or equal to t (Tail.UPPER), or either (Tail.TWO), where t is the original observed statistic value.

If access to the individual bootstrap sample statistics are required (e.g. to examine their distribution or for teaching purposes), a StatisticListener object can be supplied in the constructor, or added using the addStatisticListener method. Note that events are fired by method calculateSP(), so if the subclass calls this method from its constructor it need a non-null listener parameter.

Reference:
Efron,B. and Tibshirani,R.J.(1993). An Introduction to the Bootstrap. Chapman & Hall.

Version:
1.0
Author:
A. J. Bertie.

Field Summary
protected  Random rand
          Pseudo-random number generator for random generation of bootstrap samples.
protected  Set statisticListeners
          Set of registered objects listening for sampling events from this class.
 
Constructor Summary
BootstrapTest(double t, Tail tail, StatisticListener listener)
          Instantiate the object.
 
Method Summary
 void addStatisticListener(StatisticListener listener)
          Adds a listener for any events fired by a sampling event.
protected abstract  double bootstrapSample()
          Calculate the statistic for a single bootstrap sample.
 double calculateSP(int repCount)
          Estimate the significance probability by taking a random sample of bootstraps.
 double getSP()
          Returns the achieved significance level of the bootstrap test.
 double getTestStatistic()
          Returns value of the original observed statistic.
 long getTotalRepCount()
          Returns the total number of random bootstrap replications.
 void removeStatisticListener(StatisticListener listener)
          Remove a listener.
 void setSeed(long seed)
          Initialize the random number generator with a seed value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rand

protected Random rand
Pseudo-random number generator for random generation of bootstrap samples.


statisticListeners

protected Set statisticListeners
Set of registered objects listening for sampling events from this class.

Constructor Detail

BootstrapTest

public BootstrapTest(double t,
                     Tail tail,
                     StatisticListener listener)
Instantiate the object.

Parameters:
t - the original observed statistic value.
tail - indicates which tail of the distribution of t is to be used to calculate the SP.
listener - a listener for accessing random bootstrap statistics; or null.
Method Detail

bootstrapSample

protected abstract double bootstrapSample()
Calculate the statistic for a single bootstrap sample.

Returns:
the statistic for the sample.

calculateSP

public double calculateSP(int repCount)
Estimate the significance probability by taking a random sample of bootstraps. Calls to this method are cumulative: i.e. the SP is recalculated using all previous samples. Repeated calls could be used to assess the convergence of the SP to some value. Fires a StatisticEvent event for any registered listeners.

Parameters:
repCount - the number of random bootstrap replications.
Returns:
the recalculated approximate SP.

getSP

public double getSP()
Returns the achieved significance level of the bootstrap test. N.B. Returns NaN if method calculateSP() has not be called.

Specified by:
getSP in interface SignificanceTest
Returns:
the achieved significance level.

getTestStatistic

public double getTestStatistic()
Returns value of the original observed statistic.

Specified by:
getTestStatistic in interface SignificanceTest
Returns:
the value of the statistic.

getTotalRepCount

public long getTotalRepCount()
Returns the total number of random bootstrap replications.

Returns:
the total number of replications.

setSeed

public void setSeed(long seed)
Initialize the random number generator with a seed value. The random number generator is used to generate random bootstraps. Setting the seed is necessary if the same random samples are to be repeated.

Parameters:
seed - a seed value.

addStatisticListener

public void addStatisticListener(StatisticListener listener)
Adds a listener for any events fired by a sampling event.


removeStatisticListener

public void removeStatisticListener(StatisticListener listener)
Remove a listener.


Java Statistical Classes

Copyright © Andrew James Bertie, 2005, all rights reserved. Updated 12th Aug 2005