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 OneSampProp.</p>

 */

 

public class OneSampPropExample

{

 

    public static void main(String arg[])

    {

        DataManager dm = new DataManager();

 

        OneSampProp testclass1 =

new OneSampProp(0.05, 0.5, "less", 30, 100);

        double testStatistic = testclass1.testStatistic;

        double pValue = testclass1.pValue;

        double lowerBound = testclass1.confidenceInterval[0];

        double upperBound = testclass1.confidenceInterval[1];

 

        OneSampProp testclass2 = new OneSampProp();

        double[] confidenceInterval = testclass2.confidenceInterval(0.05, 30,

                                                          100);

        testStatistic = testclass2.testStatistic(0.5, 30, 100);

        pValue = testclass2.pValue(0.5, "greater", 30, 100);

 

        Hashtable argument1 = new Hashtable();

        argument1.put(ALPHA, 0.05);

        argument1.put(NULL_VALUE, 0.5);

        argument1.put(SIDE, "less");

        StatisticalAnalysis testclass3 = new OneSampProp(argument1, 30, 100).

                                         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();

        OneSampProp testclass4 = new OneSampProp(argument2, null);

        argument2.put(ALPHA, 0.05);

        confidenceInterval = testclass4.confidenceInterval(argument2, 30, 100);

        argument2.put(NULL_VALUE, 0.5);

        testStatistic = testclass4.testStatistic(argument2, 30, 100);

        argument2.put(SIDE, "greater");

        pValue = testclass4.pValue(argument2, 30, 100);

    }

 

}

 

Results:

The test statistic based on non-null constructor         =  -4.0

The p-value based on non-null constructor             =  0.0

The confidence interval based on non-null constructor   = [0.21 , 0.39]

 

{TEST_STATISTIC=-4.0, PROPORTION_SE_H0=0.05,

CONFIDENCE_INTERVAL=[D@10d448, POINT_ESTIMATE_SE=0.05,

POINT_ESTIMATE=0.3, PVALUE=3.167E-5}

 

Description: the confidence interval;

Classes: all classes in packages onesample and twosamples, ChisqTest,

OneWayANOVA, StatisticalInferenceTemplate, LinearRegression,

CoxRegression, KaplanMeierEstimate

 

The test statistic based on null constructor             =  -4.0

The p-value based on null constructor                 =  1.0

The confidence interval based on null constructor       = [0.21 , 0.39]

 

{TEST_STATISTIC=-4.0, PROPORTION_SE_H0=0.05,

CONFIDENCE_INTERVAL=[D@1bf216a, POINT_ESTIMATE_SE=0.05,

POINT_ESTIMATE=0.3, PVALUE=1.000}

 

See also:

Population Proportion,

Tests about a Population Proportion