Score Construction
- hddid.build_score_payload(data, nuisance_payload)[source]
Construct the doubly-robust score for Eq. (3.1) estimation.
Assembles the influence-function-based score S_hat from the estimated nuisance parameters (propensity score, conditional outcome means) and the observed outcomes, following Eq. (2.5) and (2.7) of the paper.
The score is defined as:
S_hat_i = rho_i * (Delta Y_i - (1 - pi_i) phi1_i - pi_i phi0_i)
where rho_i = (D_i - pi_i) / [pi_i (1 - pi_i)] is the propensity weight.
- Parameters:
data (ValidatedHDDIDData) – Validated input data containing outcomes, treatment, covariates, the nonparametric variable z, evaluation grid z0, and basis configuration.
nuisance_payload (NuisancePayload) – Cross-fitted nuisance estimates including pi_hat (propensity scores), phi0_hat and phi1_hat (conditional means), rho_hat (propensity weights), valid_mask, and fold assignments.
- Returns:
Contains the full-sample and valid-sample scores (s_hat, s_hat_valid), basis matrices for the sieve projection, the evaluation basis for computing f(z0), and all nuisance components needed downstream.
- Return type:
- Raises:
ValueError – If nuisance_payload dimensions do not align with data, or if basis_family / basis_degree disagree between inputs.
Notes
Implements the doubly-robust score from Eq. (2.5) and (2.7) of Ning, Peng, and Tao (2020). The propensity trimming mask is inherited from nuisance_payload.valid_mask.
Reference: Ning, Peng, and Tao (2020), arXiv preprint arXiv:2009.03151.
- class hddid.ScorePayload(delta_y, s_hat, s_hat_valid, valid_mask, fold_ids, fold_diagnostics, basis_family, basis_degree, oracle_lane, basis_matrix, x_valid, basis_valid_full, basis_design_valid, evaluation_basis, pi_hat, phi0_hat, phi1_hat, rho_hat, intercept_dropped_for_design)[source]
Doubly-robust influence-function score for Eq. (3.1) estimation.
Assembles the score S_hat = rho * (DeltaY - (1-pi)*phi1 - pi*phi0) from cross-fitted nuisance estimates and organizes the basis matrices needed for the partially-linear sieve regression.
- Parameters:
delta_y (ndarray)
s_hat (ndarray)
s_hat_valid (ndarray)
valid_mask (ndarray)
fold_ids (ndarray)
fold_diagnostics (list[FoldDiagnostics])
basis_family (str)
basis_degree (int)
oracle_lane (str)
basis_matrix (ndarray)
x_valid (ndarray)
basis_valid_full (ndarray)
basis_design_valid (ndarray)
evaluation_basis (ndarray)
pi_hat (ndarray)
phi0_hat (ndarray)
phi1_hat (ndarray)
rho_hat (ndarray)
intercept_dropped_for_design (bool)
- s_hat_valid
Score restricted to propensity-trimmed observations.
- Type:
ndarray of float, shape (n_valid,)
- fold_diagnostics
Per-fold trimming diagnostics.
- Type:
- basis_valid_full
Basis matrix restricted to valid observations.
- Type:
ndarray of float, shape (n_valid, L)
- basis_design_valid
Basis design matrix (intercept dropped if present).
- Type:
ndarray of float, shape (n_valid, L’)