statsmodels.stats.contingency_tables.SquareTable¶
-
class
statsmodels.stats.contingency_tables.
SquareTable
(table, shift_zeros=True)[source]¶ Methods for analyzing a square contingency table.
- Parameters
- tablearray_like
A square contingency table, or DataFrame that is converted to a square form.
- shift_zerosbool
If True and any cell count is zero, add 0.5 to all values in the table.
- These methods should only be used when the rows and columns of the
- table have the same categories. If `table` is provided as a
- Pandas DataFrame, the row and column indices will be extended to
- create a square table, inserting zeros where a row or column is
- missing. Otherwise the table should be provided in a square form,
- with the (implicit) row and column categories appearing in the
- same order.
- Attributes
- chi2_contribs
Returns the contributions to the chi^2 statistic for independence.
The returned table contains the contribution of each cell to the chi^2 test statistic for the null hypothesis that the rows and columns are independent.
- cumulative_log_oddsratios
Returns cumulative log odds ratios.
The cumulative log odds ratios for a contingency table with ordered rows and columns are calculated by collapsing all cells to the left/right and above/below a given point, to obtain a 2x2 table from which a log odds ratio can be calculated.
- cumulative_oddsratios
Returns the cumulative odds ratios for a contingency table.
See documentation for cumulative_log_oddsratio.
- fittedvalues
Returns fitted cell counts under independence.
The returned cell counts are estimates under a model where the rows and columns of the table are independent.
- independence_probabilities
Returns fitted joint probabilities under independence.
The returned table is outer(row, column), where row and column are the estimated marginal distributions of the rows and columns.
- local_log_oddsratios
Returns local log odds ratios.
The local log odds ratios are the log odds ratios calculated for contiguous 2x2 sub-tables.
- local_oddsratios
Returns local odds ratios.
See documentation for local_log_oddsratios.
- marginal_probabilities
Estimate marginal probability distributions for the rows and columns.
- rowndarray
Marginal row probabilities
- colndarray
Marginal column probabilities
- resid_pearson
Returns Pearson residuals.
The Pearson residuals are calculated under a model where the rows and columns of the table are independent.
- standardized_resids
Returns standardized residuals under independence.
Methods
from_data
(data[, shift_zeros])Construct a Table object from data.
homogeneity
([method])Compare row and column marginal distributions.
summary
([alpha, float_format])Produce a summary of the analysis.
symmetry
([method])Test for symmetry of a joint distribution.
Assess independence for nominal factors.
test_ordinal_association
([row_scores, …])Assess independence between two ordinal variables.
Methods
from_data
(data[, shift_zeros])Construct a Table object from data.
homogeneity
([method])Compare row and column marginal distributions.
summary
([alpha, float_format])Produce a summary of the analysis.
symmetry
([method])Test for symmetry of a joint distribution.
Assess independence for nominal factors.
test_ordinal_association
([row_scores, …])Assess independence between two ordinal variables.
Properties
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.
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.