mixle.inference.ordinal module¶
Ordinal regression and rank-correlation (concordance) measures.
When the response is ordered categories (none < mild < severe; 1–5 stars) the spacing between levels is unknown, so neither plain regression (assumes equal spacing) nor multinomial logit (throws away the order) is right. The cumulative (proportional-odds / proportional-hazards) model is:
P(Y <= k | x) = F(alpha_k - x’ beta), alpha_1 < … < alpha_{K-1},
a single coefficient vector beta with K-1 ordered thresholds. ordinal_regression()
fits this by maximum likelihood with F the logistic (ordered logit / proportional odds) or normal
(ordered probit) CDF.
The concordance measures summarise the monotone association between two ordinal variables from the
counts of concordant/discordant pairs: kendall_tau() (tau-b, tie-corrected),
goodman_kruskal_gamma(), and somers_d() (asymmetric). concordance_summary() returns
all of them with the underlying pair counts.
- class OrdinalResult(coef, thresholds, se, log_likelihood, link, n_categories)[source]
Bases:
objectFitted ordinal (cumulative-link) regression.
- Parameters:
- coef
(p,)slope coefficients (positivebeta_jraises the latent score, shifting mass toward higher categories).- Type:
- thresholds
(K-1,)ordered cut pointsalpha.- Type:
- se
(p,)standard errors forcoef.- Type:
- log_likelihood
maximised log-likelihood.
- Type:
- link
"logit"or"probit".- Type:
- n_categories
number of ordered categories
K.- Type:
- coef: ndarray
- thresholds: ndarray
- se: ndarray
- log_likelihood: float
- link: str
- n_categories: int
- predict_proba(x)[source]
Per-category probabilities
(n, K)at design rowsx.
- ordinal_regression(x, y, *, link='logit', max_iter=200)[source]
Fit a cumulative-link ordinal regression (ordered logit / probit) by maximum likelihood.
- concordance_summary(x, y)[source]
All pairwise concordance measures between two ordinal variables.
- kendall_tau(x, y)[source]
Kendall’s tau-b rank correlation (tie-corrected) between two ordinal variables.
- goodman_kruskal_gamma(x, y)[source]
Goodman–Kruskal gamma:
(C - D) / (C + D)ignoring ties.