import static java.lang.System.out;
import java.util.*;
import javastat.*;
import javastat.inference.onesample.*;
import static javastat.util.Argument.*;
import static javastat.util.Output.*;
import javastat.util.*;
/**
*
*
<p>Example: class OneSampMeanTTest.</p>
* <p>Data Source: Anderson, D. R., Sweeney, D. J. and Williams,
T. A. (2001).
* Contemporary Business
Statistics with Microsoft Excel. South-Western,
* p. 354. </p>
*/
public class OneSampMeanTTestExample
{
public
static void main(String arg[])
{
double[] testdata = {7, 8, 10, 8,
6, 9, 6, 7, 7, 8, 9, 8};
DataManager dm = new DataManager();
OneSampMeanTTest testclass1 =
new OneSampMeanTTest(0.05,
7, "greater", testdata);
double testStatistic =
testclass1.testStatistic;
double pValue = testclass1.pValue;
double lowerBound =
testclass1.confidenceInterval[0];
double upperBound =
testclass1.confidenceInterval[1];
OneSampMeanTTest testclass2 = new OneSampMeanTTest();
double[] confidenceInterval =
testclass2.confidenceInterval(0.05,
testdata);
testStatistic =
testclass2.testStatistic(7, testdata);
pValue = testclass2.pValue(7,
"equal", testdata);
Hashtable argument1 = new Hashtable();
argument1.put(NULL_VALUE, 7);
argument1.put(SIDE, "greater");
argument1.put(ALPHA, 0.05);
StatisticalAnalysis testclass3 = new OneSampMeanTTest(argument1,
testdata).statisticalAnalysis;
testStatistic = (Double)
testclass3.output.get(TEST_STATISTIC);
pValue = (Double) testclass3.output.get(PVALUE);
confidenceInterval = (double[])
testclass3.output.get(
CONFIDENCE_INTERVAL);
lowerBound = confidenceInterval[0];
upperBound = confidenceInterval[1];
Hashtable argument2 = new Hashtable();
OneSampMeanTTest testclass4 =
new OneSampMeanTTest(argument2,
null);
argument2.put(ALPHA, 0.05);
confidenceInterval = testclass4.
confidenceInterval(argument2, testdata);
argument2.put(NULL_VALUE, 7);
testStatistic =
testclass4.testStatistic(argument2, testdata);
argument2.put(SIDE, "equal");
pValue =
testclass4.pValue(argument2, testdata);
}
}
Results:
The
test statistic based on non-null constructor = 2.138
The
p-value based on non-null constructor
= 0.028
The
confidence interval based on non-null constructor = [6.978 ,
8.522]
{POINT_ESTIMATE_SE=0.351,
TEST_STATISTIC=2.138,
POINT_ESTIMATE=7.75,
CONFIDENCE_INTERVAL=[D@
PVALUE=0.0279,
DEGREE_OF_FREEDOM=11.0}
Description:
the test statistic;
Classes:
all classes in packages nonparametric, onesample, twosamples and
survival.inference, ChisqTest, OneWayANOVA, StatisticalInferenceTemplate,
LinearRegression,
CoxRegression
The
test statistic based on null constructor
= 2.138
The
p-value based on null constructor
= 0.056
The
confidence interval based on null constructor = [6.978 ,
8.522]
{TEST_STATISTIC=2.138,
CONFIDENCE_INTERVAL=[D@1389e4,
PVALUE=0.0558}
See also: