StatBean Name: HypothesisTests

Purpose: Performs hypothesis tests for means, medians, standard deviations, proportions, and rates.

DataSource: Any.

Read/Write Properties
NameTypeDescriptionPossible ValuesDefault Value
alphadoubleType I Error, as a percentage.0.0001-50.05.0
alternativeHypothesisStringType of alternative hypothesis."Not equal",
"Less than",
"Greater than"
"Not equal"
assumeEqualSigmasbooleanWhether to assume equal sigmas if comparing 2 means.true,falsetrue
class1NameStringName for first class to be used in title.Any string.""
class2NameStringName for second class to be used in title.Any string.""
missingValueExclusionStringThe method for handling records which contain missing values."Columnwise","Casewise",
"Tablewise"
"Columnwise"
nullHypothesisdoubleThe value of the null hypothesis.Any double.1.0
parameterOfInterestStringParameter to be tested."Mean",
"Median",
"Sigma",
"Proportion",
"Rate",
"Difference of Means",
"Ratio of Sigmas",
"Difference of Proportions",
"Difference of Rates",
"Difference of Medians",
"Difference of Distributions"
"Mean"
sample1VariableNameStringThe name of the column with data values for the first sample (if any).Any string.""
sample2VariableNameStringThe name of the column with data values for the first sample (if any).Any string.""
sample1MeandoubleThe mean of the first sample.Any double.Missing.
sample2MeandoubleThe mean of the second sample.Any double.Missing.
sample1ProportiondoubleThe proportion for the first sample.0.0-1.0Missing.
sample2ProportiondoubleThe proportion for the second sample.0.0-1.0Missing.
sample1RatedoubleThe rate for the first sample.0+Missing.
sample2RatedoubleThe rate for the second sample.0+Missing.
sample1SigmadoubleThe standard deviation of the first sample.>0Missing.
sample2SigmadoubleThe standard deviation of the second sample.>0Missing.
sample1SizeintThe number of observations in the first sample.1+0
sample2SizeintThe number of observations in the second sample.1+0
signTestbooleanWhether to use sign test rather than signed rank test if comparing 2 medians.true,falsefalse

Other Public Methods
NameDescriptionArgumentsReturn Value
double getPValue()Returns the P-Value for the test.NoneP-Value
double getTestStatistic()Returns the value of the test statistic.NoneTest statistic


Notes

1. For tests involving means or standard deviations, the statistics may either be supplied directly through methods such as setSample1Size or calculated from the data by specifying variable names. If specifying statistics directly, call calculateStatistics(null). If providing data, make the HypothesisTests bean a listener for a StatDataSource.

2. For tests involving medians, the data must be provided.

3. For tests involving proportions or rates, the statistics must be provided and any data is ignored.

Code Sample

//create a calculation bean
HypothesisTests hypothesistests1 = new STATBEANS.HypothesisTests();

//set the parameter to be tested
hypothesistests1.setParameterOfInterest("Sigma");

//set the sample statistics
hypothesistests1.setSample1Size(30);
hypothesistests1.setSample1Sigma(8.0);

//set the hypotheses to be tested
hypothesistests1.setNullHypothesis(10.0);

//set up a table to display results
hypothesisTestsTable hypothesistestsTable1 = new STATBEANS.HypothesisTestsTable();

//add the table to the display
add(hypothesistestsTable1);

//create a plot bean
HypothesisTestsPlot hypothesistestsPlot1 = new STATBEANS.HypothesisTestsPlot();

//add the plot to the display
add(hypothesistestsPlot1);

//make the table and plot beans listeners for changes in the calculation bean
hypothesistests1.addDataChangeListener(hypothesistestsTable1.listenerForDataChange);
hypothesistests1.addDataChangeListener(hypothesistestsPlot1.listenerForDataChange);

//instruct the calculation bean to compute the probabilities
hypothesistests1.calculateStatistics(null);