Skip to contents

Computes the standardized (G-computation) marginal difference in expected ordinal category score under a fitted proportional-odds (cumulative logit) model for a \(K\)-category ordinal outcome coded \(1, \ldots, K\): \(\mathrm{logit}\,\Pr(Y_i \le k \mid x_i) = \alpha_k - x_i^\top\beta\), \(k = 1, \ldots, K-1\). For each subject \(i\), the fitted linear predictor is decomposed into its treatment-free baseline \(\eta_{\mathrm{base},i} = x_i^\top\hat\beta - \hat\beta_{j_{\mathrm{treat}}}\, x_{i,j_{\mathrm{treat}}}\) and the counterfactual predictors \(\eta_{1,i} = \eta_{\mathrm{base},i} + \hat\beta_{j_{\mathrm{treat}}}\) (treatment column set to 1 for everyone) and \(\eta_{0,i} = \eta_{\mathrm{base},i}\) (set to 0 for everyone). The subject-level expected category score under each counterfactual is recovered from the fitted cumulative probabilities via the identity \(E[Y_i] = \sum_{k=1}^K k\,\Pr(Y_i=k) = 1 + \sum_{k=1}^{K-1} \Pr(Y_i > k) = 1 + \sum_{k=1}^{K-1} \left(1 - \mathrm{logit}^{-1}(\hat\alpha_k - \eta_i)\right)\), and the two population-averaged expected scores (mean1, mean0) and their difference (md) are returned — the ordinal analogue of gcomp_logistic_point_estimate_cpp's risk difference. Unlike gcomp_logistic_post_fit_cpp, this function computes point estimates only; no sandwich covariance, standard errors, or inferential quantities are returned despite the _post_fit name.

Usage

gcomp_ordinal_proportional_odds_post_fit_cpp(
  X_fit,
  coef_hat,
  alpha_hat,
  j_treat
)

Arguments

X_fit

Numeric matrix of predictors used to fit the model, including an intercept column if the model has one (conventionally absorbed into the thresholds alpha_hat rather than X_fit for a proportional-odds model, but this function does not enforce that).

coef_hat

Numeric vector of fitted proportional-odds regression coefficients \(\hat\beta\), same length and column order as X_fit.

alpha_hat

Numeric vector of the \(K-1\) fitted, increasing category thresholds \(\hat\alpha_1, \ldots, \hat\alpha_{K-1}\).

j_treat

1-based column index of the treatment indicator in X_fit.

Value

A list with elements mean1 (standardized expected category score under \(T=1\) for everyone), mean0 (standardized expected category score under \(T=0\) for everyone), and md (mean1 - mean0).

See also

gcomp_logistic_point_estimate_cpp for the binary-outcome analogue; gcomp_logistic_post_fit_cpp for an example of the sandwich-variance inference this function does not provide.