This program is able to generate confidence intervals of contrasts on multinomial populations at a given confidence level. Contrasts are limited to a subset of all possible contrasts:

  1. population1(class) - population2(class)
    This contrast is called: Assigned value contrast
  2. (population1(class_1) + population1(class_2) + ... + population1(class_i)) - ((population2(class_1) + population2(class_2) + ... + population2(class_i)))
    This contrast is called: Summarized contrast
    Here the total population sizes are needed. Otherwise the method counts assigned values several times.
For example if the data structure is a tree a summarized contrast of a node (class) is a subtraction from two populations with following values: The assigned values of the nodes summarized by all assigned values of the subtree.

The theoretical background is based on a work of Leo A. Goodman (Jun. 1964): Simultaneous Confidence Intervals for Contrasts Among Multinomial Populations published by the Institute of Mathematical Statistics (see paper source).

Version:
1.1
Author:
Max Schubach

Dependencies

The JSci package is needed for the quartile function of the unity normal and the chi-square distribution. JSci is published under the GNU General Public License (GPL) and can be download here.

Usage & Examples

Include JSci and Contrasts JARs in your Java Application.
Import the Contrasts class into your source-code.

import contrasts.Contrasts;

Create a new contrasts class and configurate it.

Contrasts contrasts = new Contrasts();
contrasts.setAlpha(0.05); //0.05 is default (95% Confidence Level).
contrasts.getMethods(); //getter of all possible Methods.
contrasts.setMethod("GOODMAN"); //"GOODMAN" is default.

Define your values you want to test and create a Map of them. For example:

//assigned
Map<String, Map<String, Double>> values_assigned = new HashMap<String, Map<String, Double>>();

Map<String, Double> p1_assigned = new HashMap<String, Double>();
p1.put("c1", 112.0);
p1.put("c2", 1232.0);

Map<String, Double> p2_assigned = new HashMap<String, Double>();
p2.put("c1", 1232.0);
p2.put("c2", 1243.0);

values_assigned.put("population1", p1_assigned);
values_assigned.put("population2", p2_assigned);

//summarized
Map<String, Map<String, Double>> values_summarized = new HashMap<String, Map<String, Double>>();

Map<String, Double> p1_summarized = new HashMap<String, Double>();
p1.put("c1", 1343.0);
p1.put("c2", 1231.0);

Map<String, Double> p2_summarized = new HashMap<String, Double>();
p2.put("c1", 2475.0);
p2.put("c2", 1243.0);

values_summarized.put("population1", p1_summarized);
values_summarized.put("population2", p2_summarized);

Apply values to contrasts and generate the Confidence Intervals

//assigned
contrasts.apply(values_assigned);

//summarized: need population sizes!
Map<String, Double> population_sizes = HashMap<String, Double>()
population_sizes.put("population1", 1343.0);
population_sizes.put("population2", 2475.0);
contrasts.apply(values_summarized, population_sizes); //

Get information

Some examples how to get CIs of contrasts:

// get all Confidence Intervals of the applied values
contrasts.getConfidenceIntervals();

// get the Confidence interval for the contrast population1(c1) - population2(c1)
contrasts.getClassInterval("population1", "population2", "c1");

// Similar but the contrast is now population2(c1) - population1(c1)
contrasts.getClassInterval("population2", "population1", "c1");

// Defining contrasts of interest
ArrayList<String> classes = new ArrayList<String>();
classes.put("c1"); //All contrasts of c1
classes.put("c2"); //All contrasts of c2
contrasts.getContrastsOfClasses(classes); // get all contrast intervals of the previous defined classes

Splits

Workflow how to define Splits and get the score of the Split:

// Defining the two sets
String[] set1 = new String[]{"population1"};
String[] set2 = new String[]{"population2"};

// Get the split score
// (only classes that have at least one interval different from zero are included).
contrasts.getSplitScores(set1, set2);

// Get the split score using a given set of classes.
// (only classes that have at least one interval different from zero are included).
// See "Get information" for the classes value.
contrasts.getSplitScores(set1, set2, classes);