import
static java.lang.System.out;
import java.util.*;
import javastat.*;
import
javastat.inference.*;
import
static javastat.util.Output.*;
import
javastat.util.*;
/**
*
* <p>Example: class
OneWayANOVA.</p>
* <p>Data Source: Anderson, D. R.,
Sweeney, D. J. and Williams, T. A. (2001).
* Contemporary Business
Statistics with Microsoft Excel. South-Western,
* p. 408. </p>
*/
public
class OneWayANOVAExample
{
public static void
main(String arg[])
{
double[][] anovadata1 = { {6.0, 7.0, 6.0, 8.0}, {8.0, 9.0, 8.0, 10.0},
{13.0, 14.0, 15.0} };
double[] anovadata21 = {85, 75, 82, 76, 71, 85};
double[] anovadata22 = {71, 75, 73, 74, 69, 82};
double[] anovadata23 = {59, 64, 62, 69, 75, 67};
DataManager dm = new DataManager();
OneWayANOVA testclass1 = new OneWayANOVA(anovadata1);
double testStatistic = testclass1.testStatistic;
double pValue = testclass1.pValue;
OneWayANOVA testclass2 = new OneWayANOVA();
testStatistic = testclass2.testStatistic(anovadata21, anovadata22,
anovadata23);
pValue = testclass2.pValue(anovadata21, anovadata22, anovadata23);
Hashtable argument = new Hashtable();
StatisticalAnalysis testclass3 =new OneWayANOVA(
argument, anovadata21,
anovadata22, anovadata23).
statisticalAnalysis;
testStatistic = (Double) testclass3.output.get(TEST_STATISTIC);
pValue
= (Double) testclass3.output.get(PVALUE);
OneWayANOVA testclass4 = new OneWayANOVA(argument, null);
testStatistic = testclass4.testStatistic(argument, anovadata1);
pValue = testclass4.pValue(argument, anovadata1);
}
}
Results:
The
test statistic based on non-null constructor for data set I = 49.721
The
p-value based on non-null constructor for data set I =
0.0
{DEGREE_OF_FREEDOM=[D@
TEST_STATISTIC=9.0}
The
test statistic based on null constructor for data set II =
9.0
The
p-value based on null constructor for data set II
= 0.0027
{PVALUE=3.074E-5,
TEST_STATISTIC=49.721}
See also:
An Introduction to Analysis of Variance