Skip to contents

Computes the G-computation (regression standardization) point estimate of the marginal treatment effect under a fitted logit-link model — logistic regression for a binary outcome, or the algebraically identical fractional logit / quasi-binomial model for a proportion outcome in \([0, 1]\), since the standardization formula depends only on the fitted linear predictor and link function, not the response's distributional assumptions. For each subject \(i\) in the fitted sample, 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 two counterfactual predictions \(\widehat{\Pr}(Y_i = 1 \mid \mathrm{do}(T=1)) = \mathrm{logit}^{-1}(\eta_{\mathrm{base},i} + \hat\beta_{j_{\mathrm{treat}}})\) and \(\widehat{\Pr}(Y_i = 1 \mid \mathrm{do}(T=0)) = \mathrm{logit}^{-1}(\eta_{\mathrm{base},i})\) are computed by setting every subject's treatment column to 1 (respectively 0) while leaving all other covariates at their observed values — this is standard G-computation / standardization: average the model-implied outcome over the empirical covariate distribution under each counterfactual treatment assignment. The two averages (mean1, mean0) and their difference (md, the standardized average treatment effect on the risk-difference scale) are returned.

Usage

gcomp_fractional_logit_point_estimate_cpp(X_fit, coef_hat, j_treat)

Arguments

X_fit

Numeric matrix of predictors used to fit the model, including an intercept column if the model has one.

coef_hat

Numeric vector of fitted model coefficients \(\hat\beta\), same length and column order as X_fit.

j_treat

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

Value

A list with elements mean1 (standardized mean outcome under \(T=1\) for everyone), mean0 (standardized mean outcome under \(T=0\) for everyone), and md (mean1 - mean0, the standardized risk difference).

See also

gcomp_logistic_point_estimate_cpp, which computes the identical quantity (it delegates directly to this function) under the "logistic regression" framing.