statsmodels.stats.contingency_tables.Table¶

class
statsmodels.stats.contingency_tables.
Table
(table, shift_zeros=True)[source]¶ A twoway contingency table.
 Parameters
table (arraylike) – A contingency table.
shift_zeros (boolean) – If True and any cell count is zero, add 0.5 to all values in the table.

table_orig
¶ The original table is cached as table_orig.
 Type
arraylike

marginal_probabilities
[source]¶ The estimated row and column marginal distributions.
 Type
tuple of two ndarrays

independence_probabilities
[source]¶ Estimated cell probabilities under row/column independence.
 Type
ndarray

standardized_resids
[source]¶ Residuals for the independent row/column model with approximate unit variance.
 Type
ndarray

local_logodds_ratios
¶ The local log odds ratios are calculated for each 2x2 subtable formed from adjacent rows and columns.
 Type
ndarray

local_oddsratios
[source]¶ The local odds ratios are calculated from each 2x2 subtable formed from adjacent rows and columns.
 Type
ndarray

cumulative_log_oddsratios
[source]¶ The cumulative log odds ratio at a given pair of thresholds is calculated by reducing the table to a 2x2 table based on dichotomizing the rows and columns at the given thresholds. The table of cumulative log odds ratios presents all possible cumulative log odds ratios that can be formed from a given table.
 Type
ndarray

cumulative_oddsratios
[source]¶ The cumulative odds ratios are calculated by reducing the table to a 2x2 table based on cutting the rows and columns at a given point. The table of cumulative odds ratios presents all possible cumulative odds ratios that can be formed from a given table.
 Type
ndarray
See also
statsmodels.graphics.mosaicplot.mosaic
,scipy.stats.chi2_contingency
Notes
The inference procedures used here are all based on a sampling model in which the units are independent and identically distributed, with each unit being classified with respect to two categorical variables.
References
 Definitions of residuals:
Methods
Returns the contributions to the chi^2 statistic for independence.
Returns cumulative log odds ratios.
Returns the cumulative odds ratios for a contingency table.
Returns fitted cell counts under independence.
from_data
(data[, shift_zeros])Construct a Table object from data.
Returns fitted joint probabilities under independence.
Returns local log odds ratios.
Returns local odds ratios.
Estimate marginal probability distributions for the rows and columns.
Returns Pearson residuals.
Returns standardized residuals under independence.
Assess independence for nominal factors.
test_ordinal_association
([row_scores, …])Assess independence between two ordinal variables.