: t = crosstab (x1, x2)
Function File: t = crosstab (x1, ..., xn)
Function File: [t, chi-2, p, labels] = crosstab (...)

Create a cross-tabulation (contingency table) t from data vectors.

The inputs x1, x2, ... xn must be vectors of equal length with a data type of numeric, logical, char, or string (cell array).

As additional return values crosstab returns the chi-square statistics chi-2, its p-value p and a cell array labels, containing the labels of each input argument.

Currently chi-2 and p are available only for 1 or 2-dimensional t, with crosstab returning a NaN value for both chi-2 and p for 3-dimensional, or more, t.

See also: grp2idx,tabulate.

Package: statistics