SSJ
V. 2.6.2.

umontreal.iro.lecuyer.gof
Class GofStat.OutcomeCategoriesChi2

java.lang.Object
  extended by umontreal.iro.lecuyer.gof.GofStat.OutcomeCategoriesChi2
Enclosing class:
GofStat

public static class GofStat.OutcomeCategoriesChi2
extends Object

This class helps managing the partitions of possible outcomes into categories for applying chi-square tests. It permits one to automatically regroup categories to make sure that the expected number of observations in each category is large enough. To use this facility, one must first construct an OutcomeCategoriesChi2 object by passing to the constructor the expected number of observations for each original category. Then, calling the method regroupCategories will regroup categories in a way that the expected number of observations in each category reaches a given threshold minExp. Experts in statistics recommend that minExp be always larger than or equal to 5 for the chi-square test to be valid. Thus, minExp = 10 is a safe value to use. After the call, nbExp gives the expected numbers in the new categories and loc[i] gives the relocation of category i, for each i. That is, loc[i] = j means that category i has been merged with category j because its original expected number was too small, and nbExp[i] has been added to nbExp[j] and then set to zero. In this case, all observations that previously belonged to category i are redirected to category j. The variable nbCategories gives the final number of categories, smin contains the new index of the lowest category, and smax the new index of the highest category.


Field Summary
 int[] loc
          loc[i] gives the relocation of the category i in the nbExp array.
 int nbCategories
          Total number of categories.
 double[] nbExp
          Expected number of observations for each category.
 int smax
          Maximum index for valid expected numbers in the array nbExp.
 int smin
          Minimum index for valid expected numbers in the array nbExp.
 
Constructor Summary
GofStat.OutcomeCategoriesChi2(double[] nbExp)
          Constructs an OutcomeCategoriesChi2 object using the array nbExp for the number of expected observations in each category.
GofStat.OutcomeCategoriesChi2(double[] nbExp, int[] loc, int smin, int smax, int nbCat)
          Constructs an OutcomeCategoriesChi2 object.
GofStat.OutcomeCategoriesChi2(double[] nbExp, int smin, int smax)
          Constructs an OutcomeCategoriesChi2 object using the given nbExp expected observations array.
 
Method Summary
 void regroupCategories(double minExp)
          Regroup categories as explained earlier, so that the expected number of observations in each category is at least minExp.
 String toString()
          Provides a report on the categories.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nbCategories

public int nbCategories
Total number of categories.


smin

public int smin
Minimum index for valid expected numbers in the array nbExp.


smax

public int smax
Maximum index for valid expected numbers in the array nbExp.


nbExp

public double[] nbExp
Expected number of observations for each category.


loc

public int[] loc
loc[i] gives the relocation of the category i in the nbExp array.

Constructor Detail

GofStat.OutcomeCategoriesChi2

public GofStat.OutcomeCategoriesChi2(double[] nbExp)
Constructs an OutcomeCategoriesChi2 object using the array nbExp for the number of expected observations in each category. The smin and smax fields are set to 0 and (n - 1) respectively, where n is the length of array nbExp. The loc field is set such that loc[i]=i for each i. The field nbCategories is set to n.

Parameters:
nbExp - array of expected observations for each category

GofStat.OutcomeCategoriesChi2

public GofStat.OutcomeCategoriesChi2(double[] nbExp,
                                     int smin,
                                     int smax)
Constructs an OutcomeCategoriesChi2 object using the given nbExp expected observations array. Only the expected numbers from the smin to smax (inclusive) indices will be considered valid. The loc field is set such that loc[i]=i for each i in the interval [smin, smax]. All loc[i] for i  <=  smin are set to smin, and all loc[i] for i  >=  smax are set to smax. The field nbCategories is set to (smax - smin + 1).

Parameters:
nbExp - array of expected observations for each category
smin - Minimum index for valid expected number of observations
smax - Maximum index for valid expected number of observations

GofStat.OutcomeCategoriesChi2

public GofStat.OutcomeCategoriesChi2(double[] nbExp,
                                     int[] loc,
                                     int smin,
                                     int smax,
                                     int nbCat)
Constructs an OutcomeCategoriesChi2 object. The field nbCategories is set to nbCat.

Parameters:
nbExp - array of expected observations for each category
smin - Minimum index for valid expected number of observations
smax - Maximum index for valid expected number of observations
loc - array for which loc[i] gives the relocation of the category i
Method Detail

regroupCategories

public void regroupCategories(double minExp)
Regroup categories as explained earlier, so that the expected number of observations in each category is at least minExp. We usually choose minExp = 10.

Parameters:
minExp - mininum number of expected observations in each category

toString

public String toString()
Provides a report on the categories.

Overrides:
toString in class Object
Returns:
the categories represented as a string

SSJ
V. 2.6.2.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.