Class TableMultiWay
- All Implemented Interfaces:
Serializable,Cloneable
The TableMultiWay class determines the distinct values in
multivariate data and computes frequencies for the data. This class accepts
the data in the matrix x, but performs computations only for the
variables (columns) in the first nKeys columns of
x or by the variables specified in indkeys. In
general, the variables for which frequencies should be computed are discrete;
they should take on a relatively small number of different values. Variables
that are continuous can be grouped first. TableMultiWay can be
used to group variables and determine the frequencies of groups.
When method getBalancedTable is called, the inner class
BalancedTable fills the vector values with the unique values in
the vector of the variables and tallies the number of unique values of each
variable table. Each combination of one value from each variable forms a cell
in a multi-way table. The frequencies of these cells are entered in a table
so that the first variable cycles through its values exactly once, and the
last variable cycles through its values most rapidly. Some cells cannot
correspond to any observations in the data; in other words, "missing cells"
are included in table and have a value of 0. The frequency table is returned
by the BalancedTable method getTable.
When method getUnbalancedTable is called, an instance of inner
class UnbalancedTable is created, the frequency of each cell is
entered in the unbalanced table so that the first variable cycles through its
values exactly once and the last variable cycles through its values most
rapidly. table is returned by UnbalancedTable
method getTable. All cells have a frequency of at least 1, i.e.,
there is no "missing cell." The array listCells, returned by
method getListCells can be considered "parallel" to
table because row i of listCells is the set of
nKeys values that describes the cell for which row i of
table contains the corresponding frequency.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassTallies the number of unique values of each variable.classTallies the frequency of each cell inx. -
Constructor Summary
ConstructorsConstructorDescriptionTableMultiWay(double[][] x, int nKeys) Constructor forTableMultiWay.TableMultiWay(double[][] x, int[] indkeys) Constructor forTableMultiWay. -
Method Summary
Modifier and TypeMethodDescriptionReturns an object containing the balanced table.int[]Returns the number of observations (rows) in each group.Returns an object containing the unbalanced table.voidsetFrequencies(double[] frequencies) Sets the frequencies for each observation in x.
-
Constructor Details
-
TableMultiWay
public TableMultiWay(double[][] x, int nKeys) Constructor forTableMultiWay.- Parameters:
x- Adoublematrix containing the observations and variables.nKeys-intequal to the number of keys. The firstnKeysvariables (columns) ofxare to be used as the sorting keys.
-
TableMultiWay
public TableMultiWay(double[][] x, int[] indkeys) Constructor forTableMultiWay.- Parameters:
x- Adoublematrix containing the observations and variables.indkeys-intarray containing the variables (columns) which are to be used as the sorting keys.
-
-
Method Details
-
getGroups
public int[] getGroups()Returns the number of observations (rows) in each group. The number of groups is the length of the returned array. A group contains observations inxthat are equal with respect to the method of comparison. Ifncontains the returned integer array, then the firstn[0]rows of the sortedxare group number 1. The nextn[1]rows of the sortedxare group number 2, etc. The lastn[n.length - 1]rows of the sortedxare group numbern.length.- Returns:
- an
intarray containing the number of observations (row) in each group.
-
getBalancedTable
Returns an object containing the balanced table.- Returns:
- a
TableBalanced object.
-
getUnbalancedTable
Returns an object containing the unbalanced table.- Returns:
- a
TableUnBalanced object.
-
setFrequencies
public void setFrequencies(double[] frequencies) Sets the frequencies for each observation in x. The length of the input must be the same as the number of observations or number of rows inx.- Parameters:
frequencies- adoublearray containing the frequency for each observation in x. Defaultfrequencies[] =1.
-