statsmodels.stats.contingency_tables.Table2x2.test_ordinal_association

Table2x2.test_ordinal_association(row_scores=None, col_scores=None)

Assess independence between two ordinal variables.

This is the ‘linear by linear’ association test, which uses weights or scores to target the test to have more power against ordered alternatives.

Parameters:
row_scoresarray_like

An array of numeric row scores

col_scoresarray_like

An array of numeric column scores

Returns:
A bunch with the following attributes:
statisticfloat

The test statistic.

null_meanfloat

The expected value of the test statistic under the null hypothesis.

null_sdfloat

The standard deviation of the test statistic under the null hypothesis.

zscorefloat

The Z-score for the test statistic.

pvaluefloat

The p-value for the test.

Notes

The scores define the trend to which the test is most sensitive.

Using the default row and column scores gives the Cochran-Armitage trend test.