API Reference
All estimators follow a common two-step API:
solver = <SolverClass>(O, Z, ...) # attach data
result = solver.fit(...) # run the algorithm
Result Objects
Every fit() call returns a subclass of Result.
The table below lists all attributes you can read off each result object.
Common attributes (available on every result)
Attribute |
Description |
|---|---|
|
ATT estimate — scalar, or array for multi-treatment solvers. |
|
Fitted counterfactual panel (N × T ndarray). |
|
Original observed outcome panel (N × T). |
|
Original treatment mask (N × T). |
|
Standard deviation of |
|
Covariance matrix of |
|
String describing the inference approach (or |
|
|
|
Residuals restricted to treated cells |
|
Detected treatment pattern: |
|
RMSE on all Z=0 cells (computed property). |
|
RMSE on pure control units across all time periods (computed property). |
|
RMSE on all units before first treatment (computed property). |
|
R² on Z=0 cells — scale-free model-fit diagnostic. |
|
Print a formatted diagnostics table. |
|
Interactive Plotly figure for one unit. |
Estimator-specific attributes
Estimator |
Attribute |
Description |
|---|---|---|
DID |
|
Unit FE vector (N,) |
|
Time FE vector (T,) |
|
|
Covariate coefficients (K,) — |
|
SDID |
|
Donor unit weights |
|
Time weights |
|
MC-NNM |
|
Low-rank component of counterfactual (N×T) |
|
Unit FE vector (N,) |
|
|
Time FE vector (T,) |
|
|
Covariate coefficients (K,) — |
|
DC-PR |
|
De-biased counterfactual panel (N×T) |
|
Sandwich SE for |
|
OLS SC |
|
List of simplex weight vectors, one per
treated unit. |
|
Per-unit ATT list
|
|
|
Row indices of donor units (list[int]) |
|
|
Row indices of treated units (list[int]) |
|
|
Predictor importance weights (list) when covariates are used. |
|
Covariance PCA |
|
Left factor matrix (N × r ndarray) |
RSC |
|
Low-rank counterfactual panel (N×T) |
Quick access examples:
# DID
result = DIDPanelSolver(O, Z).fit()
result.row_fixed_effects # unit FE, shape (N,)
result.column_fixed_effects # time FE, shape (T,)
# SDID
result = SDIDPanelSolver(O, Z).fit()
result.unit_weights # donor weights, shape (N,)
result.time_weights # time weights, shape (T,)
# MC-NNM
result = MCNNMPanelSolver(O, Z).fit()
result.M # low-rank component only
result.row_fixed_effects # unit FE, shape (N,)
result.column_fixed_effects # time FE, shape (T,)
result.beta # covariate coefs (or None)
# DC-PR
result = DCPanelSolver(O, Z).fit()
result.std # sandwich SE
# OLS Synthetic Control
result = OLSSCPanelSolver(O, Z).fit()
result.beta[0] # donor weights for first treated unit
result.individual_te # [[unit_idx, tau_hat], ...]
result.control_units # donor row indices
result.treatment_units # treated row indices
# Covariance PCA
result = CovariancePCAPanelSolver(O, Z).fit()
result.U # left factor matrix (N × r)
# RSC
result = RSCPanelSolver(O, Z).fit()
result.M # low-rank counterfactual
Difference-in-Differences (DID)
Synthetic Difference-in-Differences (SDID)
De-biased Convex Panel Regression (DC-PR)
Matrix Completion with Nuclear Norm Minimisation (MC-NNM)
Covariance PCA
OLS Synthetic Control (SC)
Robust Synthetic Control (RSC)
Data Utilities
Synthetic Data Generation
Use generate() to create a fully controlled
panel from a low-rank factor model. The function returns (O, Z, tau_true)
so ground-truth evaluation is always possible.
Semi-Synthetic Experiments
Use real panel data as a baseline, inject a known synthetic treatment effect, and benchmark estimators under controlled conditions.