SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Public Attributes | List of all members
GofStat.OutcomeCategoriesChi2 Class Reference

This class helps managing the partitions of possible outcomes into categories for applying chi-square tests. More...

Public Member Functions

 OutcomeCategoriesChi2 (double[] nbExp)
 Constructs an OutcomeCategoriesChi2 object using the array nbExp for the number of expected observations in each category. More...
 
 OutcomeCategoriesChi2 (double[] nbExp, int smin, int smax)
 Constructs an OutcomeCategoriesChi2 object using the given nbExp expected observations array. More...
 
 OutcomeCategoriesChi2 (double[] nbExp, int[] loc, int smin, int smax, int nbCat)
 Constructs an OutcomeCategoriesChi2 object. More...
 
void regroupCategories (double minExp)
 Regroup categories as explained earlier, so that the expected number of observations in each category is at least minExp. More...
 
String toString ()
 Provides a report on the categories. More...
 

Public Attributes

int nbCategories
 Total number of categories.
 
int smin
 Minimum index for valid expected numbers in the array nbExp.
 
int smax
 Maximum index for valid expected numbers in the array nbExp.
 
double [] nbExp
 Expected number of observations for each category.
 
int [] loc
 loc[i] gives the relocation of the category i in the nbExp array.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ OutcomeCategoriesChi2() [1/3]

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
nbExparray of expected observations for each category

◆ OutcomeCategoriesChi2() [2/3]

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 \(\le\) smin are set to smin, and all loc[i] for i \(\ge\) smax are set to smax. The field nbCategories is set to (smax - smin + 1).

Parameters
nbExparray of expected observations for each category
sminMinimum index for valid expected number of observations
smaxMaximum index for valid expected number of observations

◆ OutcomeCategoriesChi2() [3/3]

OutcomeCategoriesChi2 ( double []  nbExp,
int []  loc,
int  smin,
int  smax,
int  nbCat 
)

Constructs an OutcomeCategoriesChi2 object.

The field nbCategories is set to nbCat.

Parameters
nbExparray of expected observations for each category
sminMinimum index for valid expected number of observations
smaxMaximum index for valid expected number of observations
locarray for which loc[i] gives the relocation of the category i

Member Function Documentation

◆ regroupCategories()

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
minExpmininum number of expected observations in each category

◆ toString()

String toString ( )

Provides a report on the categories.

Returns
the categories represented as a string

The documentation for this class was generated from the following file: