PropensityScore.fit_outcome_model#

PropensityScore.fit_outcome_model(X_outcome, y, coords, priors={'b_outcome': [0, 1], 'beta_ps': [0, 1], 'sigma': 1}, noncentred=True, normal_outcome=True, spline_component=False, winsorize_boundary=0.0)[source]#

Fit a Bayesian outcome model using covariates and previously estimated propensity scores.

This function implements the second stage of a modular two-step causal inference procedure. It uses propensity scores extracted from a prior treatment model (via self.fit()) to adjust for confounding when estimating treatment effects on an outcome variable y.

Parameters:
  • X_outcome (array-like, shape (n_samples, n_covariates)) – Covariate matrix for the outcome model.

  • y (array-like, shape (n_samples,)) – Observed outcome variable.

  • coords (dict) – Coordinate dictionary for named dimensions in the PyMC model. Should include a key “outcome_coeffs” for X_outcome.

  • priors (dict, optional) –

    Dictionary specifying priors for outcome model parameters:
    • ”b_outcome”: list [mean, std] for regression coefficients.

    • ”sigma”: standard deviation of the outcome noise (default 1).

  • noncentred (bool, default True) – If True, use a non-centred parameterization for the outcome coefficients.

  • normal_outcome (bool, default True) – If True, assume a Normal likelihood for the outcome. If False, use a Student-t likelihood with unknown degrees of freedom.

  • spline_component (bool, default False) – If True, include a spline basis expansion on the propensity score to allow flexible (nonlinear) adjustment. Uses B-splines with 30 internal knots.

  • winsorize_boundary (float, default 0.0) – If we wish to winsorize the propensity score this can be set to clip the high and low values of the propensity at 0 + winsorize_boundary and 1-winsorize_boundary

Returns:

  • idata_outcome (arviz.InferenceData) – The posterior and prior predictive samples from the outcome model.

  • model_outcome (pm.Model) – The PyMC model object.

Raises:

AttributeError – If the self.idata attribute is not available, which indicates that fit() (i.e., the treatment model) has not been called yet.

Notes

  • This model uses a sampled version of the propensity score (p) from the

posterior of the treatment model, randomly selecting one posterior draw per call. This term is estimated initially in the InversePropensity class initialisation. - The term beta_ps[0] * p captures both main effects of the propensity score. - Including spline adjustment enables modeling nonlinear relationships between the propensity score and the outcome.