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:
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).
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.
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.
Classes | Population1 | Population2 |
---|---|---|
c1 | 112 | 1232 |
c2 | 1231 | 1243 |
Classes | Population1 | Population2 |
---|---|---|
c1 | 1343 | 2475 |
c2 | 1231 | 1243 |
//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);
//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 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
// 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);