JMSLTM Numerical Library 7.2.0
com.imsl.stat

## Class TableMultiWay

• All Implemented Interfaces:
Serializable, Cloneable

```public class TableMultiWay
extends Object
implements Serializable, Cloneable```
Tallies observations into a multi-way frequency table.

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.

Example, Example, Example, Serialized Form
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`class ` `TableMultiWay.BalancedTable`
Tallies the number of unique values of each variable.
`class ` `TableMultiWay.UnbalancedTable`
Tallies the frequency of each cell in `x`.
• ### Constructor Summary

Constructors
Constructor and Description
```TableMultiWay(double[][] x, int nKeys)```
Constructor for `TableMultiWay`.
```TableMultiWay(double[][] x, int[] indkeys)```
Constructor for `TableMultiWay`.
• ### Method Summary

Methods
Modifier and Type Method and Description
`TableMultiWay.BalancedTable` `getBalancedTable()`
Returns an object containing the balanced table.
`int[]` `getGroups()`
Returns the number of observations (rows) in each group.
`TableMultiWay.UnbalancedTable` `getUnbalancedTable()`
Returns an object containing the unbalanced table.
`void` `setFrequencies(double[] frequencies)`
Sets the frequencies for each observation in x.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### TableMultiWay

```public TableMultiWay(double[][] x,
int nKeys)```
Constructor for `TableMultiWay`.
Parameters:
`x` - A `double` matrix containing the observations and variables.
`nKeys` - `int` equal to the number of keys. The first `nKeys` variables (columns) of `x` are to be used as the sorting keys.
• #### TableMultiWay

```public TableMultiWay(double[][] x,
int[] indkeys)```
Constructor for `TableMultiWay`.
Parameters:
`x` - A `double` matrix containing the observations and variables.
`indkeys` - `int` array containing the variables (columns) which are to be used as the sorting keys.
• ### Method Detail

• #### getBalancedTable

`public TableMultiWay.BalancedTable getBalancedTable()`
Returns an object containing the balanced table.
Returns:
a `TableBalanced object`.
• #### 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 in `x` that are equal with respect to the method of comparison. If `n` contains the returned integer array, then the first `n[0]` rows of the sorted `x` are group number 1. The next `n[1]` rows of the sorted `x` are group number 2, etc. The last `n[n.length - 1]` rows of the sorted `x` are group number `n.length`.
Returns:
an `int` array containing the number of observations (row) in each group.
• #### getUnbalancedTable

`public TableMultiWay.UnbalancedTable 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 in `x`.
Parameters:
`frequencies` - a `double` array containing the frequency for each observation in x. Default `frequencies`[] =1.
JMSLTM Numerical Library 7.2.0