Panel Data Approach (PDA)

Contents

Panel Data Approach (PDA)#

When to Use This Estimator#

The panel data approach (PDA) of Hsiao, Ching and Wan [HCW] estimates a single treated unit’s untreated counterfactual by a linear regression on the control units, fit over the pre-treatment window and extrapolated out-of-sample. Unlike the synthetic control method, PDA imposes no constraints on the coefficients (no simplex, no non-negativity), so it is a plain projection justified by a latent-factor model: if every unit loads on a small set of common factors, the treated unit’s untreated path is a linear combination of the controls’ paths plus an orthogonal error.

The challenge is which controls and how many. Classical PDA was built for low dimensions (few controls relative to pre-periods) and chooses controls by AIC/BIC, which break down once the number of controls N approaches or exceeds the pre-period length T0. mlsynth packages the original Hsiao-Ching-Wan method together with four high-dimensional variants that resolve the N-near-T0 problem differently, each with the estimation and inference theory of its own paper:

  • Original best-subset (hcw; Hsiao, Ching & Wan [HCW2012]) – the method that started the literature. The counterfactual is an unrestricted OLS regression (with intercept) of the treated pre-period on the best subset of controls, the subset and its size chosen by AICc (also AIC / BIC). Built for the low-dimensional regime (a moderate, pre-screened candidate pool); the best-subset search is combinatorial, so cap hcw_nvmax or pre-restrict the pool for large N. The three estimators below are its scalable descendants.

  • L2-relaxation (l2; Shi & Wang [l2relax]) – a dense estimator (a “cousin of ridge”) for when the factor model makes the projection coefficients dense; tolerates N > T0; prediction is robust to heteroskedasticity.

  • LASSO (lasso; Li & Bell [LASSOPDA]) – an L1 estimator that selects a sparse set of relevant controls; computationally far cheaper than AIC/BIC and works for N > T0.

  • Forward selection (fs; Shi & Huang [fsPDA]) – a greedy procedure that grows the control set one unit at a time, with valid post-selection inference and no sparsity requirement (works for dense or sparse models). The scalable replacement for hcw’s combinatorial best-subset search.

  • Random forest (rf; Liu, Long & Luo [rfPDA]) – a random forest ranks the controls by permutation importance and a forward search walks down that ranking, keeping the prefix with the smallest held-out error. The ranking is nonparametric, so a control earns its place by predicting the treated unit under whatever functional form, and the search costs 2N forests.

All variants target the single-treated-unit, many-candidate-controls regime and produce a time-varying treatment effect and an average treatment effect (ATE) with a HAC-based confidence interval. The practical choice among them (detailed below) follows the authors’ own arguments: l2 when the coefficients are dense, lasso when only a few controls matter and you want an interpretable selection, fs when you want a cheap, predictive ensemble with honest post-selection inference regardless of sparsity.

Notation#

We use mlsynth’s standard notation, with the two sample operators of Shi & Wang [l2relax] defined below. For a positive integer n, \([n] = \{1, \ldots, n\}\); \(\mathbf{I}_n\) is the identity, \(\mathbf{1}_n\), \(\mathbf{0}_n\) the all-ones/zeros vectors. For a matrix \(\mathbf{A} = (a_{ij})\) and index sets \(\mathcal{S}, \mathcal{Q}\), the submatrix is \(\mathbf{A}_{\mathcal{S}\mathcal{Q}} = (a_{ij})_{i\in\mathcal{S}, j\in\mathcal{Q}}\) and the subvector \(\mathbf{x}_{\mathcal{Q}} = (x_i)_{i\in\mathcal{Q}}\). \(\phi_{\min}(\cdot)\), \(\phi_{\max}(\cdot)\) denote the smallest and largest eigenvalues; \(\|\mathbf{A}\|_\infty = \max_{ij}|a_{ij}|\), \(\|\mathbf{A}\|_2 = \sqrt{\phi_{\max}(\mathbf{A}'\mathbf{A})}\), \(\|\mathbf{x}\|_1 = \sum_i |x_i|\).

The two time-series operators are central. Over an index set \(\mathcal{S}\) of periods,

\[\mathcal{E}_{\mathcal{S}}(\mathbf{x}_t) = \frac{1}{|\mathcal{S}|} \sum_{t\in\mathcal{S}} \mathbf{x}_t, \qquad \Gamma_{\mathcal{S}}(\mathbf{x}_t, \mathbf{y}_t') = \mathcal{E}_{\mathcal{S}} \Bigl( [\mathbf{x}_t - \mathcal{E}_{\mathcal{S}}(\mathbf{x}_t)] [\mathbf{y}_t - \mathcal{E}_{\mathcal{S}}(\mathbf{y}_t)]' \Bigr),\]

the sample mean and sample covariance of a series over \(\mathcal{S}\). The intervention takes effect after the split point \(T_0\). The pre-period is \(\mathcal{T}_1 \coloneqq \{1, \ldots, T_0\}\) with \(|\mathcal{T}_1| = T_0\); the post-period is \(\mathcal{T}_2 \coloneqq \{T_0+1, \ldots, T\}\) with \(T_2 \coloneqq |\mathcal{T}_2| = T - T_0\). Let \(j=1\) denote the treated unit, with treated series \(\mathbf{y}_1 = (y_{11}, \ldots, y_{1T})^\top\); the donor pool is \(\mathcal{N}_0 \coloneqq \mathcal{N}\setminus\{1\}\), with cardinality \(N_0\), where \(\mathcal{N} = \{1,\ldots,N\}\).

The shared model#

All four methods rest on a common latent-factor data-generating process: for \(t \in \mathcal{T}\),

\[y_{jt}^N = \mu_j + \boldsymbol{\lambda}_j' \mathbf{f}_t + u_{jt}, \quad j \in \{1\}\cup\mathcal{N}_0,\]

with \(\mathbf{f}_t\) an \(r\)-vector of latent common factors, \(\boldsymbol{\lambda}_j\) factor loadings, and \(u_{jt}\) a weakly-dependent idiosyncratic error orthogonal to the factors. Because the common factors drive both the treated unit and the donors, the untreated treated outcome admits a linear projection on the donors,

\[y_{1t} = \alpha^0 + \mathbf{x}_t' \boldsymbol{\beta}^0 + \epsilon_t, \qquad \mathbf{x}_t = (y_{jt})_{j\in\mathcal{N}_0}',\]

with \(\mathbb{E}[\mathbf{x}_t \epsilon_t] = \mathbf{0}\). PDA fits \((\alpha^0, \boldsymbol{\beta}^0)\) on \(\mathcal{T}_1\) and predicts \(\widehat{y}_{1t} = \mathcal{E}_{\mathcal{T}_1}(y_{1s}) + [\mathbf{x}_t - \mathcal{E}_{\mathcal{T}_1}(\mathbf{x}_s)]'\widehat{\boldsymbol{\beta}}\) for \(t \in \mathcal{T}_2\). The per-period treatment effect is \(\tau_t = y_{1t} - \widehat{y}_{1t}\) and the ATE \(\widehat{\tau} = \mathcal{E}_{\mathcal{T}_2}(\tau_t)\). The methods differ in how they estimate \(\boldsymbol{\beta}\) and in the inference theory each paper proves for \(\widehat{\tau}\).

Original best subset (hcw, Hsiao-Ching-Wan)#

Idea. This is the method that started the literature [HCW2012]. The recipe is the plainest one in the family – ordinary least squares of the treated unit’s pre-period outcome on a handful of control series, extrapolated past the intervention – with one twist: which controls, and how many, are chosen for you, not fixed in advance. HCW’s Section 5 turns that choice into a model-selection problem. It helps to walk through it as four steps.

Step 1 – measure how well a candidate set of controls fits. Pick any subset \(\mathcal{S}\subseteq\mathcal{N}_0\) of the donors. Regress the treated pre-period outcome on those donors and an intercept by OLS, and record the residual sum of squares – the total squared pre-period miss,

\[\mathrm{RSS}(\mathcal{S}) = \min_{\alpha,\,\boldsymbol{\beta}_{\mathcal{S}}} \sum_{t\in\mathcal{T}_1} \bigl(y_{1t} - \alpha - \mathbf{x}_{t,\mathcal{S}}' \boldsymbol{\beta}_{\mathcal{S}}\bigr)^2 , \qquad \mathbf{x}_{t,\mathcal{S}} = (y_{jt})_{j\in\mathcal{S}}.\]

A smaller \(\mathrm{RSS}\) means a tighter pre-period fit. By itself it is not a usable score, though: adding any control can only lower \(\mathrm{RSS}\), so “smallest RSS” always points at the largest possible model, which memorises the short pre-period and extrapolates badly past the cut.

Step 2 – charge for complexity with an information criterion. To stop the search from simply taking every donor, each subset is scored by an information criterion: the (log) fit plus a penalty that grows with the number of parameters. The default is the small-sample-corrected AICc (AIC and BIC are the same shape with a lighter or heavier penalty),

\[\mathrm{AICc}(\mathcal{S}) = \underbrace{T_0 \log\!\frac{\mathrm{RSS} (\mathcal{S})}{T_0}}_{\text{rewards fit}} + \underbrace{2K + \frac{2K(K+1)}{T_0 - K - 1}}_{\text{charges for size}}, \qquad K = r + 2,\;\; r = |\mathcal{S}|.\]

Lower is better. The first term falls as the fit improves; the second rises with the model size \(r\), so the criterion bottoms out where one more donor stops paying for the variance it adds – the bias-variance trade-off turned into a single number. The penalised parameter count \(K = r + 2\) counts the \(r\) donors, the intercept, and the error variance (the convention of the pampe R package, leaps::regsubsets + AICc + lm); the small-sample correction \(2K(K+1)/(T_0-K-1)\) matters because PDA’s pre-period is short.

Step 3 – keep the subset with the best score. The selected controls are the global minimiser

\[\widehat{\mathcal{S}} = \operatorname*{argmin}_{\mathcal{S}\subseteq \mathcal{N}_0,\; |\mathcal{S}|\le r_{\max}} \mathrm{AICc}(\mathcal{S}).\]

In practice this is computed the way leaps does it (HCW Section 5): for each model size \(r\) find the single lowest-\(\mathrm{RSS}\) subset of that size, then choose the size whose best subset minimises the criterion – a “best of each size, then choose the size” search. The cap \(r_{\max}\) (hcw_nvmax, pampe’s nvmax) limits the largest size considered and cannot exceed the pre-period degrees of freedom (the criterion is undefined once the donors plus intercept use up the \(T_0\) observations).

Step 4 – refit and extrapolate. Re-fit OLS on the chosen controls \(\widehat{\mathcal{S}}\) over the pre-period, then carry the coefficients forward: the counterfactual is that fitted line evaluated on the post-period control values, and the per-period effect is treated minus counterfactual, exactly as in the shared model above. On HCW’s Hong Kong sovereignty study this selects \(\{\text{Japan},\text{Korea},\text{Taiwan},\text{USA}\}\) with \(\mathrm{AICc} = -171.771\), reproducing Table XVI value-for-value (cross-validated against pampe – see the benchmark below).

Best subset selection is HCW’s classical, low-dimensional choice: AICc / AIC / BIC are only defined while \(r < T_0\), and the search is combinatorial in \(N_0\). HCW therefore pre-screened the donor pool (limiting Hong Kong to ten candidate economies). [HTT2020] place best subset alongside its two cheaper relatives – forward stepwise and the lasso – and show forward stepwise tracks best subset closely, which is exactly why fs is hcw’s scalable descendant; lasso and l2 are the others. Use hcw when the candidate pool is moderate and pre-screened, when you want the original method or to reproduce HCW / pampe, and when an exact, certified optimum is the point.

Computing the best subset: the optimisation#

There are \(2^{N_0}\) candidate subsets, each an OLS fit, so naive enumeration is the regime where even leaps strains. mlsynth solves the problem exactly with a branch-and-bound built on three ideas, plus an optional fourth that hands the problem to a mixed-integer solver.

Furnival-Wilson sweep engine. The default is the canonical leaps::regsubsets algorithm [FurnivalWilson]: a depth-first search over subsets driven by the symmetric sweep operator on the augmented cross-product matrix \([\mathbf{1},\mathbf{X},\mathbf{y}]' [\mathbf{1},\mathbf{X},\mathbf{y}]\). Sweeping a donor in leaves the running \(\mathrm{RSS}\) in the response diagonal in \(O(p^2)\), and the reverse sweep removes it on backtracking, so no OLS is ever re-solved from scratch. Each subtree is bounded below by the smallest \(\mathrm{RSS}\) it can reach (include every remaining donor – \(\mathrm{RSS}\) is monotone in the variable set) paired with the smallest information-criterion penalty any descendant can carry; when that lower bound cannot beat the incumbent, the whole subtree is pruned. The bound is a true lower bound, so the returned subset is the exact global optimum – identical to exhaustive enumeration, at a small fraction of the cost.

Discrete first-order warm start. The incumbent is seeded, at every model size, with the Bertsimas-King-Mazumder projected-gradient hard-thresholding method [BKM2016] (their Algorithm 1): iterate \(\boldsymbol{\beta}\leftarrow H_r\!\bigl(\boldsymbol{\beta} - \tfrac{1}{L} \nabla g(\boldsymbol{\beta})\bigr)\), where \(H_r\) keeps the \(r\) largest-magnitude coordinates and \(L\) upper-bounds the largest eigenvalue of the centred donor Gram, with a least-squares refit on the active set and several restarts. A near-optimal incumbent tightens the bound from the outset and prunes more subtrees; because the seed can only lower the incumbent, the certified optimum is unchanged.

Node budget and a certified optimality gap. For a pool too large to certify quickly, the search stops at a node budget and returns the best incumbent found together with a valid lower bound – the smallest subtree bound it never reached. The reported \(\text{optimality gap} = \text{incumbent} - \text{lower bound}\) is then a genuine suboptimality certificate (zero means provably optimal), the Bertsimas-King-Mazumder gap obtained from the branch-and-bound’s own bounds with no solver. This replaces an outright refusal of large pools: fits["hcw"].metadata reports certified_optimal and optimality_gap.

Optional exact mixed-integer backend. Setting hcw_backend="scip" certifies the optimum at pool sizes beyond the branch-and-bound’s exact reach via the SCIP solver. It casts the size-\(r\) problem as the Bertsimas-King-Mazumder cardinality-constrained least squares – binary indicators \(z_i\), an SOS-1 coupling forcing \(z_i = 0 \Rightarrow \beta_i = 0\), and \(\sum_i z_i \le r\) – solved once per size, then chooses the size by the criterion. The dependency is optional: pyscipopt is imported only on demand (pip install mlsynth[scip]). The default fw backend needs no solver and is all the low-dimensional regime hcw targets requires.

Assumptions and inference. hcw shares the identifying stack documented under Shared assumptions across the PDA class (the latent factor model A1, single absorbing treatment A2, weak temporal dependence A3), specialised to the low-dimensional regime \(N_0 < T_0\) that makes the information criteria well-defined. Inference mirrors the post-selection HAC machinery of the scalable variants: the average effect carries a Newey-West / Bartlett long-run-variance confidence interval (prewhitened by default; lrvar_lag switches to a fixed-lag Bartlett estimator), and prediction_intervals=True attaches the Jiang et al. per-period intervals described below.

Testing the extrapolation (hcw_holdout)#

Steps 1 to 4 choose the controls and the coefficients by minimising the pre-period residual sum of squares, and then push that fitted relation past \(T_0\). The pre-period fit cannot tell you whether the second half of that sentence is safe, because it is the quantity the first half minimised. With a short pre-period the two come apart: a regression with an intercept and one control fits any three points closely, and reports a small \(\mathrm{RSS}\) whether or not the relation it found is the one that holds out of sample.

Setting hcw_holdout=L measures the difference. An origin \(o\) slides across the pre-period; at each one, hcw refits on periods \(\mathcal{T} = \{1, \dots, o\}\) alone and predicts the next \(L\) periods, which that refit never saw:

\[e_t \;=\; y_t \;-\; \left( \hat{\mu}^{(o)} + \sum_{j \in \hat{S}^{(o)}} \hat{\beta}^{(o)}_j \, y_{jt} \right), \qquad t = o+1, \dots, o+L .\]

Origins step by \(L\), so the windows do not overlap and no period is scored twice. The earliest origin leaves the widest control model a residual degree of freedom, which is a lower floor than the one the conformal band machinery uses: a band calibrated on a degenerate fit would report that degeneracy instead of the method’s error, whereas a pre-period too short to extrapolate is exactly the condition this diagnostic exists to report.

The summary is the ratio

\[\mathrm{ratio} \;=\; \frac{\mathrm{RMSE}_{\text{held out}}} {\mathrm{RMSE}_{\text{in sample}}} ,\]

held-out error over the error of the full pre-period fit. Near one, the fit extrapolates about as well as it interpolates. Much above one, the coefficients are tracking the pre-period and the post-period counterfactual rests on a relation the data has not tested. The ratio is scale-free, so it reads the same across panels measured in different units.

The result is a PDAHoldout on the fit:

res = PDA(PDAConfig(df=df, unitid="unit", time="time", outcome="y",
                    treat="D", method="hcw", hcw_holdout=2)).fit()
h = res.fits["hcw"].holdout
h.ratio            # held-out RMSE / in-sample RMSE
h.errors           # per-period out-of-sample errors, in time order
h.origins          # the origins scored

When the pre-period admits no origin at all – too few periods for the training floor and one whole window – nothing is scored, the summary fields are nan, and a warning says so. That is a result: the extrapolation the estimator is about to perform is untested, and the panel cannot test it.

An example of the gap this closes. Aleman, Busch, Santaeulalia-Llopis and Surovtseva (2026) estimate the effect of California’s 1988 minimum wage rise by regressing California’s mean retail wage on a control group’s over four pre-policy years, then extrapolating. The four-point fit is tight. Extending the same regression to nine pre-policy years moves the slope from 0.66 to 1.15, takes its confidence interval from one that covers 1 to one that excludes it, and roughly halves the estimated effect. The pre-period fit statistic is similar in both specifications; a holdout separates them.

L2-relaxation (l2, Shi & Wang)#

Idea. Under the factor model the projection coefficient \(\boldsymbol{\beta}^0 = \boldsymbol{\Omega}^{-1}\boldsymbol{\Lambda} (\boldsymbol{\Lambda}'\boldsymbol{\Omega}^{-1}\boldsymbol{\Lambda} + \mathbf{I}_q)^{-1}\boldsymbol{\lambda}_1\) is dense in general – almost no entries are exactly zero. Sparse methods (LASSO) are then mis-matched. With \(\widehat{\boldsymbol{\Sigma}} = \Gamma_{\mathcal{T}_1}(\mathbf{x}_t, \mathbf{x}_t')\) and \(\widehat{\boldsymbol{\eta}} = \Gamma_{\mathcal{T}_1}(\mathbf{x}_t, y_t)\), OLS solves the KKT condition \(\widehat{\boldsymbol{\Sigma}}\boldsymbol{\beta} = \widehat{\boldsymbol{\eta}}\), which is unstable or non-unique once \(N\) is close to or exceeds \(T_0\). L2-relaxation relaxes the sup-norm of this moment condition by a tuning parameter \(\varepsilon\) and minimizes the coefficient norm:

\[\min_{\boldsymbol{\beta}} \tfrac{1}{2}\|\boldsymbol{\beta}\|_2^2 \quad \text{s.t.} \quad \|\widehat{\boldsymbol{\eta}} - \widehat{\boldsymbol{\Sigma}}\boldsymbol{\beta}\|_\infty \le \varepsilon.\]

This is the “bias-variance trade-off” made explicit: tolerating a small violation \(\varepsilon\) of the OLS moment condition shrinks the variance. At \(\varepsilon = 0\) it reduces to (ridgeless) OLS; at \(\varepsilon \ge \|\widehat{\boldsymbol{\eta}}\|_\infty\) it gives \(\boldsymbol{\beta} = \mathbf{0}\). mlsynth picks \(\varepsilon\) by sequential out-of-sample validation on the tail of the training window (the validated \(\varepsilon\) tracks the infeasible-optimal one, and both shrink toward zero as the sample grows) over a log-spaced grid down to \(10^{-4}\max|\widehat{\boldsymbol{\eta}}|\) (the optimum is often a tiny fraction of the cap). This is time-respecting – the fit never sees periods later than the validation tail – unlike the released L2relax.CV, whose 5-block K-fold trains on both past and future of each block.

Solving the grid, and reading the solver#

The grid and the fit ask the solver for different things. The fit is the estimate that gets reported, so it is solved to \(10^{-9}\); the grid only has to order its candidates by validation error, and its winner is refit afterwards. That distinction is most of the runtime of an l2 fit. As \(\varepsilon\) shrinks the feasible set thins toward the moment condition \(\widehat{\boldsymbol{\Sigma}}\boldsymbol{\beta} = \widehat{\boldsymbol{\eta}}\), and the small-\(\varepsilon\) end of the grid drives the ADMM solver to its iteration cap: at \(N = 400\) donors on \(T_0 = 150\) pre-periods, an eighty-point grid takes 271 s at \(10^{-9}\) and 25 s at \(10^{-6}\), and picks the same \(\varepsilon\).

The solver also answers with a status, and that status has to be read. On a pre-period where \(\widehat{\boldsymbol{\Sigma}}\) is near-singular – 24 Hong Kong donors on 24 periods, so its rank is 23 – OSQP returns a primal infeasibility certificate at the small-\(\varepsilon\) end. The certificate is false there, since the smallest reachable \(\|\widehat{\boldsymbol{\eta}} - \widehat{\boldsymbol{\Sigma}}\boldsymbol{\beta}\|_\infty\) is about \(10^{-12}\), well below the \(\varepsilon\) it fires at. Either way a certificate is not a solution to the problem that was posed, and its vector is finite – entries of order \(10^{9}\) on that panel – so a finiteness check alone admits it into the validation ranking. mlsynth keeps the statuses that carry a primal iterate, imprecise ones included, and refuses the rest; an \(\varepsilon\) with no fit drops out of the ranking, and a grid with no fit anywhere raises.

Note

Standardisation. Following the authors’ released L2relax, the treated and control series are standardised (demeaned and scaled to unit variance) before forming \(\widehat{\boldsymbol{\Sigma}}\) / \(\widehat{\boldsymbol{\eta}}\), and the solution is mapped back to the original scale. This is the default (l2_standardize=True) – the \(\ell_2\) penalty is scale-sensitive, so standardisation is both recommended and what reproduces the paper’s empirical results; on the Hong Kong panel it moves the L2 estimate from \(2.48\%\) to \(2.61\%\) (closer to Shi & Wang’s \(2.65\%\)). Set l2_standardize=False for the raw-scale variant.

Assumptions (Shi & Wang).

Assumption 1 (loadings). \(\|\boldsymbol{\lambda}_1\|_\infty + \|\boldsymbol{\Lambda}\|_\infty \le C\), and there is an \(r\)-unit subset making \(\boldsymbol{\Lambda}_{\mathcal{Q}\cdot}\) full column rank; the average factor strength \(\xi_N = \phi_{\min}(\boldsymbol{\Lambda}' \boldsymbol{\Lambda}/N)\) may vanish (weak factors allowed).

Remark. Bounded loadings keep the projection coefficient well-defined, while the full-rank subset is what lets the donors span the treated unit’s factor exposure; allowing \(\xi_N \to 0\) means the method tolerates weak factors that contribute little cross-sectional variation.

Assumption 2 (errors). The idiosyncratic covariance \(\boldsymbol{\Omega}\) has eigenvalues bounded between \(\underline\sigma^2\) and \(\overline\sigma^2\); errors may be heteroskedastic and cross-sectionally dependent.

Remark. The two-sided eigenvalue bound rules out a degenerate noise direction, but heteroskedastic, cross-sectionally dependent errors are permitted – the realistic case for economic panels.

Assumption 3-4 (sampling). In- and out-of-sample sampling errors of the sample moments are \(O_p(T_0^{-1/2})\) for low-dimensional pieces and \(O_p(\sqrt{\log N / (N\wedge T_0)})\) for high-dimensional ones (holding under time-series weak dependence, not just i.i.d.).

Remark. These are the convergence rates that make the relaxed moment condition usable in high dimension: the high-dimensional pieces pay only a \(\sqrt{\log N}\) price, so \(N\) may grow with (or beyond) \(T_0\).

Assumption 5 (ATE inference). The oracle prediction error \(\epsilon_t^*\) and the effect-plus-error \(d_t^* = \Delta_t - \mathbb{E}[\Delta_t] + \epsilon_t^*\) have finite, positive long-run variances \(\rho^2_{\epsilon^*}\), \(\rho^2_{d^*}\) consistently estimable by HAC, and a sequential CLT applies.

Remark. The coefficient estimator is consistent for the oracle target (Theorem 1) and the prediction error is asymptotically irrelevant to heteroskedasticity (Theorem 2): unlike the coefficient MSE, the out-of-sample MSE does not depend on the noise heterogeneity \(\psi_{\max}\). This is what licenses the HAC-based CLT for the ATE.

Inference (Shi & Wang, Theorem 3; single treated unit). With pre-period prediction residuals \(e_t = y_{1t} - \widehat{y}_{1t}\) (\(t\in\mathcal{T}_1\)) and post-period effects \(\tau_t\) (\(t\in\mathcal{T}_2\)),

\[\widehat{Z} = \frac{\widehat{\tau} - \Delta_{\mathcal{T}_2}} {\sqrt{\widehat{\rho}^2_{(1)}/T_0 + \widehat{\rho}^2_{(2)}/T_2}} \xrightarrow{d} N(0,1),\]

where \(\widehat{\rho}^2_{(1)}\) is the HAC long-run variance of the pre-period residuals (first-stage estimation uncertainty) and \(\widehat{\rho}^2_{(2)}\) is the HAC long-run variance of the de-meaned post-period effects (post-period averaging). Both sources of uncertainty enter, which matters when \(T_0\) and \(T_2\) are comparable.

When to use. Dense, factor-driven coefficients; high dimension (\(N>T_0\) permitted); when prediction accuracy and heteroskedasticity- robustness matter more than identifying a handful of controls.

LASSO (lasso, Li & Bell)#

Idea. When only a few controls are truly relevant, an L1 penalty selects them and shrinks the rest. Li & Bell estimate

\[\widehat{\boldsymbol{\beta}}^{\text{las}} = \operatorname*{argmin}_{\boldsymbol{\beta}} \; \sum_{t\in\mathcal{T}_1} (y_{1t} - \mathbf{x}_t'\boldsymbol{\beta})^2 + \lambda \sum_{j} |\beta_j|,\]

with \(\lambda\) chosen by (leave-one-out) cross-validation, then predict the counterfactual as in the shared model. LASSO works for \(N > T_0\) (where AIC/AICC/BIC cannot even be computed) and is far cheaper.

Assumptions (Li & Bell). They relax HCW’s linear-conditional-mean assumption and drop one of HCW’s identification conditions. The key conditions are: a factor model with \(\mathrm{Rank}(\widetilde{B}) = K\) (enough independent factor variation among the controls); a weakly dependent, weakly stationary panel so laws of large numbers and CLTs apply to partial sums; consistency of the pre-period least-squares pieces (\(\widehat{\delta}_1 - \delta_1, \widehat{\delta}-\delta = O_p(T_0^{-1/2})\)); and \(\rho\)-mixing with geometric decay plus a finite limit \(\eta = \lim T_2/T_0\). Sparsity (only \(m\) of \(\boldsymbol{\beta}\) non-zero, \(m\) fixed or \(o(T_0)\)) is assumed for the high-dimensional selection.

Remark. Li & Bell prove consistency \(\widehat{\tau} - \Delta_{\mathcal{T}_2} = O_p(T_0^{-1/2} + T_2^{-1/2})\) (estimation error has two parts: first-stage \(O_p(T_0^{-1/2})\) and post-averaging \(O_p(T_2^{-1/2})\)), holding even when \(y_{1t}\) is trend-stationary.

Inference (Li & Bell, Theorem 3.2). With \(\widehat{\Sigma} = \widehat{\Sigma}_1 + \widehat{\Sigma}_2\),

\[\text{T.S.} = \frac{\sqrt{T_2}\,\widehat{\tau}}{\sqrt{\widehat{\Sigma}}} \xrightarrow{d} N(0,1),\]

where \(\widehat{\Sigma}_2\) is the Newey-West HAC long-run variance of the post-period effects, and \(\widehat{\Sigma}_1\) is the first-stage (pre-period estimation) variance – the OLS prediction variance of the mean post-period counterfactual on the selected support. Li & Bell note \(\widehat{\Sigma}_1\) is negligible when \(T_0 \gg T_2\), so the post-period term dominates in long-pre-period panels. When \(T_0\) is comparable to \(T_2\) it is not negligible at all: on Shi & Huang’s Monte Carlo design, where \(T_0 = T_2\), it accounts for 44-46% of \(\widehat{\Sigma}\) and inflates the standard error by about a third.

Supplying lrvar_lag selects a different test – Shi & Huang’s, the one their lasso.BIC computes:

\[Z = \frac{\widehat{\tau}}{\sqrt{\widehat{\omega}(h) / T_2}},\]

with \(\widehat{\omega}(h)\) the Bartlett long-run variance of the post-period effects at the truncation lag \(h\) and no first-stage term. Pair it with lasso_criterion="mbic" to reproduce lasso.BIC end to end; mlsynth’s \(Z\) then matches theirs to \(7\times 10^{-6}\) on the panels carried in the fspda_dense_mc benchmark bundle.

When to use. A genuinely sparse set of relevant controls; very large \(N\) (even \(N/T_0 \to \infty\)); when an interpretable, computa- tionally cheap selection is preferred. (For selection consistency, Li & Bell note the adaptive LASSO; for prediction, plain LASSO already beats AIC/BIC and leave-many-out CV in their simulations.)

Choosing \(\lambda\): lasso_criterion#

Cross-validation is one rule for the penalty and it is the default here, but it is not the rule every paper in this literature uses. Shi & Huang’s fsPDA package selects the penalty by an information criterion instead – the same modified BIC their forward selection uses, applied along the LASSO path:

\[\mathrm{IC}(\lambda) = \log\bigl(\widehat{\sigma}^2(\lambda)\bigr) + H\,\log(\log N)\,\frac{\log T_0}{T_0}\,k(\lambda),\]

where \(\widehat{\sigma}^2(\lambda)\) is the pre-period mean squared residual, \(k(\lambda)\) counts the selected donors, and \(H\) is a constant the authors tune “to allow Lasso to take in more variables” (Remark 4 cont., p. 521). The minimiser over their grid \(\lambda \in \{0.01, 0.02, \dots, 1\}\) is the penalty.

Set lasso_criterion="mbic" to use it, and lasso_mbic_const to set \(H\) (their default is 2; a smaller value selects more donors, a larger one fewer). Three things move together:

lasso_criterion="cv" (default)

lasso_criterion="mbic"

penalty

5-fold cross-validation

argmin of \(\mathrm{IC}(\lambda)\) over their grid

intercept

fitted

none (glmnet(..., intercept = FALSE))

donor scaling

raw

divided by each column’s standard deviation, coefficients returned on the original scale (standardize = TRUE)

The intercept and the scaling are part of the rule. The criterion scores a particular fit, so the estimate it selects a penalty for has to be that fit; changing only the criterion gives a penalty chosen for a model the estimator never fits. The port agrees with glmnet 4.1.8 to 5e-09 on the scaled path.

Which to use. Cross-validation targets prediction and is the safer default when the donor pool is a convenience sample and you have no reason to prefer one sparsity level. Use mbic when you are comparing against Shi & Huang or another fsPDA-based result, or when you want the selection to be scale-explicit and deterministic – it has no fold randomness, so the same panel always returns the same donors.

Forward selection (fs, Shi & Huang)#

Idea. Instead of penalize, grow the control set greedily. Start empty; at each step add the control whose inclusion maximizes the pre-treatment OLS \(R^2\) (equivalently minimizes the residual sum of squares). The number of selected controls \(R\) is a tuning parameter chosen by a modified BIC (Wang, Li & Tsai),

\[\widehat{R} = \operatorname*{argmin}_{r} \log\bigl(\widehat{\sigma}^2(\widehat{U}_r)\bigr) + \log(\log N)\,\frac{r\,\log T_0}{T_0},\]

with \(\widehat{\sigma}^2(\widehat{U}_r)\) the pre-period residual variance of OLS on the \(r\)-unit set. The counterfactual is the OLS extrapolation on the chosen set \(\widehat{U}_{\widehat{R}}\). Forward selection evaluates \(\sum_r (N-r+1)\) regressions – linear in \(N\) – versus the \(2^N\) of exhaustive subset search.

Computing the greedy step#

The step as the paper states it. At step \(r\), with \(\widehat{U}_r\) the donors already chosen, forward selection scores every remaining donor by the pre-period fit its admission would produce, and keeps the best:

\[j^\star = \operatorname*{argmin}_{j \notin \widehat{U}_r} \widehat{\sigma}^2\bigl(\widehat{U}_r \cup \{j\}\bigr), \qquad \widehat{\sigma}^2(S) = \frac{1}{T_0}\, \min_{\boldsymbol{\beta}} \bigl\lVert \mathbf{y}_1 - \mathbf{X}_S\,\boldsymbol{\beta} \bigr\rVert_2^2 .\]

Read literally that is \(N - r\) separate least-squares problems per step, each on a \(T_0 \times (r+1)\) design, and the recursion repeats them from scratch at every step.

The step as mlsynth computes it. Let \(P_r\) be the orthogonal projection onto the span of the chosen donors (the constant adjoined when one is fitted), and write

\[\mathbf{e}_r = (\mathbf{I} - P_r)\,\mathbf{y}_1, \qquad \mathbf{z}_j = (\mathbf{I} - P_r)\,\mathbf{x}_j\]

for the current pre-period residual and for a candidate donor orthogonalised against that span. The fit after admitting \(j\) is then available in closed form,

\[T_0\,\widehat{\sigma}^2\bigl(\widehat{U}_r \cup \{j\}\bigr) = \bigl\lVert\mathbf{e}_r\bigr\rVert_2^2 - \Delta_j, \qquad \Delta_j = \frac{\bigl(\mathbf{x}_j^\top\mathbf{e}_r\bigr)^2} {\bigl\lVert\mathbf{z}_j\bigr\rVert_2^2},\]

with \(\mathbf{x}_j^\top\mathbf{e}_r = \mathbf{z}_j^\top\mathbf{e}_r\) because \(\mathbf{e}_r\) is orthogonal to the span by construction. The subtracted term is the only part that depends on \(j\), so the two selection rules coincide:

\[\operatorname*{argmin}_{j \notin \widehat{U}_r} \widehat{\sigma}^2\bigl(\widehat{U}_r \cup \{j\}\bigr) \;=\; \operatorname*{argmax}_{j \notin \widehat{U}_r} \Delta_j .\]

All \(N - r\) numerators are one matrix-vector product \(\mathbf{Z}^\top\mathbf{e}_r\), and the denominators reach the next step through a rank-one downdate of \(\mathbf{Z}\). A donor lying inside the span has \(\lVert\mathbf{z}_j\rVert_2 = 0\) and contributes \(\Delta_j = 0\), which is the closed form saying it cannot lower the residual.

What differs, and what does not. The displayed equality is an identity in exact arithmetic, not an approximation, so the two rules select the same donor. The criterion \(\mathrm{IC}(r)\) still reads a \(\widehat{\sigma}^2\) returned by an ordinary least-squares solve on the design the step selects, so the stopping rule is evaluated on the same quantity in both forms. What changes is the arithmetic spent getting there:

Form of the step

Arithmetic per step

Least-squares solves per step

Scoring by refitting

\(O(N T_0 r^2)\)

\(N - r\)

Scoring by projection

\(O(T_0 N)\)

\(1\)

Where the difference is felt. A single fit on \(N = 1000\) donors over \(T_0 = 300\) pre-periods goes from 189 ms to 7.7 ms. The effect compounds wherever the selection is re-run: setting prediction_intervals=True refits the estimator on every bootstrap sample (999 by default – see the prediction-interval section), so a forward-selected fit with intervals on 120 donors goes from 22.3 s to 1.3 s.

The estimate is unchanged, and the benchmarks check it – fspda_dense_mc reproduces the released R package’s selected set on 8 of 8 Monte Carlo cells, with coefficients, ATE and z-statistic agreeing to \(10^{-13}\); fspda_sparse_mc agrees with the authors’ nonsparse/FS.R rule on 30 of 30 panels; pda_table1 and pda_luxurywatch return the values they returned before.

Where the two forms can name different donors. Donors that fit the pre-period identically – an exact duplicate of a selected donor, or a pool spanning fewer directions than it has members – carry equal \(\Delta_j\) up to rounding. The search settles such a tie by the least-squares comparison itself, across a bounded number of the tied candidates, and on the pools an applied panel presents it selects what the definition selects. Two regimes sit outside that bound: a tied group larger than the shortlist, and a pre-period that has interpolated. In the second, once \(\mathbf{y}_1\) lies exactly in the donor span the residual falls to the level of rounding noise, and each further step compares one \(\widehat{\sigma}^2\) of order \(10^{-31}\) against another; both forms admit a few extra donors, and which ones follows the floating-point library. In either regime the donors named can differ within a set that fits the pre-period equally well, the extras carry coefficients at the \(10^{-16}\) level, and the counterfactual agrees to machine precision.

Assumptions (Shi & Huang). Asymptotics are multi-index: \(N\to\infty\) with \(T_0 = T_0(N)\) deterministic, \(\log N / T_0 \to 0\), and \(T_2 = T_2(N) \to \infty\) with \(\log N / T_2 \to 0\) (\(N\) may exceed \(T_0\)).

Assumption 1 (sparse Riesz / restricted eigenvalue). The minimal eigenvalue of the population Gram matrix over any \(u\)-unit subset (\(u \le (1+\delta_1)R\)) is bounded below – a condition the authors show is a natural implication of the latent factor model, not an ad hoc restriction.

Remark. The bounded minimal eigenvalue is what keeps any candidate subset of donors well-conditioned, so the greedy step can identify the next informative control, not chase a near-singular direction; that it follows from the factor model means it is not an extra demand on the data.

Assumption 2 (second moments). Sample second moments converge at the high-dimensional rate \(O_p(\sqrt{\log N / T_0})\) with bounded fourth moments.

Remark. The high-dimensional rate is the pre-period price of admitting many donors: with bounded fourth moments the sample Gram matrix tracks its population counterpart even when \(N\) is large relative to \(T_0\).

Assumption 3 (post-period). Analogous convergence and long-run-variance bounds on the post-treatment data.

Remark. The matching post-period bounds are what let the average effect over \(\mathcal{T}_2\) obey a central limit theorem with a consistently estimable long-run variance, the basis for the post-selection test below.

Assumption 4 (weak dependence). The series are strong (\(\alpha\)-) mixing with geometric decay, so a Berry-Esseen bound for heterogeneous time series applies.

Remark. The validity is uniform over a class of DGPs (Theorem 1) – it holds whether the true coefficients are dense or sparse, which separates fsPDA from the post-selection-inference literature that needs sparsity or the oracle property. Theorem 2 shows the greedy algorithm attains a regression variance asymptotically as small as the best \(u\)-unit subset, so the cheap forward search is statistically efficient.

Inference (Shi & Huang, Eq. 4). Because forward selection uses only the pre-period and, under weak dependence, the pre- and post-periods become asymptotically independent (sample splitting), the naive conditional t-statistic is valid:

\[\widehat{\mathcal{Z}}_{\widehat{U}} = \widehat{\rho}_{\tau\widehat{U}}^{-1}\sqrt{T_2}\, \widehat{\tau}_{\widehat{U}} \xrightarrow{d} N(0,1),\]

where \(\widehat{\rho}^2_{\tau\widehat{U}}\) is the HAC long-run variance of the de-meaned post-period effects. No first-stage variance term is needed – the asymptotic independence absorbs it – which makes fsPDA’s inference the simplest of the three.

Note

Long-run-variance estimator. mlsynth defaults to the prewhitened Newey-West estimator (Andrews-Monahan VAR(1) prewhitening + Bartlett kernel with the data-driven NW(1994) bandwidth + finite-sample adjustment) – R’s sandwich::lrvar(..., prewhite = TRUE, adjust = TRUE), which Shi & Huang use in their application scripts. Prewhitening is essential when the treatment-effect series is strongly serially dependent: monthly growth rates mean-revert (lag-1 autocorrelation around \(-0.45\) in the luxury-watch panel), and a plain Bartlett kernel cannot absorb that, leaving \(\widehat\rho\) nearly double its true value and the test far too conservative. Setting lrvar_lag instead switches to the released est.fsPDA package’s fixed-lag Bartlett estimator (default lag \(\lfloor T_2^{1/4}\rfloor\), capped at \(\lfloor\sqrt{T_2}\rfloor\)); on the watch panel that no-prewhitening form gives an insignificant \(t \approx -1.15\), versus the prewhitened default’s \(-2.51\) (the paper reports \(-2.457\)). The field is read by fs, hcw and lasso, and it means the same thing in all three: studentize by the fixed-lag Bartlett long-run variance of the post-period effects alone. For lasso that also drops Li & Bell’s first-stage term, since the test being selected is the one that does not have it.

When to use. A large candidate-control pool where the goal is to synthesize an ensemble that mimics the outcome (not to interpret which controls are “causal”); when computational efficiency and honest post-selection inference matter; and regardless of whether the underlying model is sparse. (Shi & Huang recommend the adaptive LASSO instead when the identity of a few causal controls is the object of interest.)

Random forest (rf, Liu, Long & Luo)#

The three high-dimensional variants above all score a control by what it contributes to a linear fit. Liu, Long and Luo [rfPDA] score it by what it contributes to a prediction, and let a random forest say what that is.

The procedure has two parts. A forest is grown on the pre-treatment data and each control \(j\) is ranked by its permutation importance, the increase in prediction error when that control’s values are permuted,

\[\Upsilon_j \;=\; \mathbb{E}\big[(y_{0t}^0 - \hat\mu_{\mathcal N j} (\tilde{\mathbf y}_{\mathcal N j}, \mathcal Y))^2\big] \;-\; \mathbb{E}\big[(y_{0t}^0 - \hat\mu(\tilde{\mathbf y}, \mathcal Y))^2\big],\]

so a control that carries predictive content raises the error when it is noised. Ranking the pool in descending \(\Upsilon_j\) gives an ordered list \(\{y_{(1)}, \ldots, y_{(n)}\}\), and the second part walks down it: for each prefix \(U_i = \{y_{(1)}, \ldots, y_{(i)}\}\) the forest’s held-out mean squared error is computed, and the selected set is

\[\hat U \;=\; \Big\{ U_i \;:\; i = \arg\min_{j} \mathrm{MSE}_j \Big\}.\]

Only \(2n\) forests are fitted, against the \(2^n\) subsets the original best-subset search enumerates and the \((n + \tfrac12)R - \tfrac12 R^2\) models forward selection fits for a target size \(R\). The counterfactual is then PDA’s: OLS of the treated pre-period on \(\hat U\) with an intercept, extrapolated after \(T_0\).

Inference is the test statistic of Equation (8),

\[\mathcal Z_{\hat U} \;=\; \hat\sigma_{\hat U}^{-1} \sqrt{T_2}\, \hat\Delta_{\hat U} \;\xrightarrow{\;\mathbb H_0\;}\; N(0, 1),\]

whose long-run variance \(\hat\sigma^2_{\hat U} = \hat\gamma^2_{1} + \hat\gamma^2_{2}\) is the West [West1997] estimator built on a moving-average model of the prediction error, fitted separately on the pre- and post-treatment windows. The authors model the error as an MA and not an autoregression because it exhibits short memory and a high tendency towards stationarity, which is the regime an MA describes at PDA’s sample sizes.

Three settings. rf_split chooses how the pre-treatment window is divided. temporal (the default) takes three disjoint blocks in time order – training, validation, testing – which is Section 2.2 of the paper, and keeps later observations out of earlier fits. random reproduces the released RF.R, which samples a train/test split of the pre-treatment rows and has no validation block; the published estimates were computed that way, so it is what reproduces them.

rf_k_max caps the number of selected controls, at \(T_0 - 2\) by default. Assumption 3 of the paper requires \(|\hat U| / T_1 \to 0\), and the released search runs the prefix length to \(n - 1\) with nothing enforcing it. When the search passes \(T_0\) the pre-period OLS interpolates exactly, the residual falls to rounding, and the long-run variance it is standardised by collapses with it. Measured over twenty seeds on the paper’s own panels this happens in 7 of 20 Brexit fits and 4 of 20 luxury-watch fits, returning test statistics of \(-17.8\) and \(-966336\) at a p value of zero. Passing a value above \(T_0 - 2\) reproduces the released search and sets cap_exceeds_pre_periods on the fit’s metadata.

rf_n_seeds re-runs the selection on consecutive seeds and reports the spread. The estimate stays the fit at rf_seed, so the estimator is a function of its arguments; what the diagnostic adds is how much of the answer that argument decides. On the luxury-watch panel the ATE over twenty seeds runs from \(-0.063\) to \(-0.003\) around a published \(-0.0266\), and across twenty Brexit seeds every one of the 167 available controls is selected by some seed, with a mean pairwise selection overlap of 0.156. A single seed reports a point from that distribution.

When to use. A large candidate pool where the relation between the treated unit and the controls need not be linear for the ranking to find the right ones, and where the cost of hcw’s enumeration is prohibitive. The counterfactual is still a linear projection, so the nonparametric step buys a better ordering, not a nonlinear fit. Report the seed spread with the estimate.

Choosing among the four#

Method

Coefficient structure

Inference variance

Use when

l2

dense (factor-implied)

pre + post HAC (both terms)

dense coefficients; N>T0; prediction & heteroskedasticity-robustness

lasso

sparse

post HAC (+ first stage, small if T0>>T2)

few relevant controls; interpretable selection; very large N

fs

dense or sparse

post HAC only (sample splitting)

large pool; predictive ensemble; cheap; honest post-selection inference

rf

dense or sparse

pre + post West MA long-run variance

large pool; nonparametric ranking; report the seed spread

Shared assumptions across the PDA class#

The four estimators (l2, lasso, fs, rf) differ in how they fit \(\boldsymbol\beta\), but they share the same identifying stack. Stated formally:

A1 (Latent factor model for untreated outcomes). All \(N + 1\) units share at most \(r\) common latent factors,

\[y_{jt}^N \;=\; \mu_j \;+\; \boldsymbol\lambda_j' \mathbf f_t \;+\; u_{jt}, \qquad j \in \{1\} \cup \mathcal N_0, \;\; t \in \mathcal T,\]

with \(\mathbb E[\mathbf f_t u_{jt}] = 0\). This is the shared model underlying HCW (Hsiao-Ching-Wan 2012), Li-Bell (2017), Shi-Huang (2023), and Shi-Wang (l2). The factor structure is what licenses the linear projection of the treated unit’s untreated outcome on the controls’ outcomes,

\[y_{1t} \;=\; \alpha^0 \;+\; \mathbf x_t' \boldsymbol\beta^0 \;+\; \epsilon_t, \qquad \mathbb E[\mathbf x_t \epsilon_t] = \mathbf 0,\]

with \(\boldsymbol\beta^0 = \boldsymbol\Omega^{-1} \boldsymbol\Lambda (\boldsymbol\Lambda' \boldsymbol\Omega^{-1} \boldsymbol\Lambda + \mathbf I_q)^{-1} \boldsymbol\lambda_1\).

A2 (Single treated unit, sharp absorbing aggregate-level treatment). Unit \(j = 1\) is the only treated unit; treatment turns on at \(T_0 + 1\) and stays on. Donors are untreated throughout (no interference). The original HCW / Li-Bell / Shi-Huang theorems are stated for this single-treated case. (The l2-relaxation paper Section 4.4 sketches a multiple-treated-units extension with a short post-window; the mlsynth implementation tracks the single-treated form.)

A3 (Weak temporal dependence). The series \((\mathbf x_t, y_{1t})\) are \(\rho\)-mixing or strong- mixing with at-least-geometric decay (the exact rate varies by variant):

  • Li-Bell A6: \(w_t = (\widetilde y_t', \epsilon_{1t})\) is a weakly stationary \(\rho\)-mixing process with \(\rho(s) = O(\lambda^s)\).

  • Shi-Huang A4: strong (\(\alpha\)-) mixing with geometric decay, so a Berry-Esseen bound for heterogeneous time series applies.

  • Shi-Wang A3-A4: time-series weak dependence at the \(O_p(T_0^{-1/2})\) and \(O_p(\sqrt{\log N / (N \wedge T_0)})\) rates for the sample moments.

This is what makes pre-period sample moments converge at the high-dimensional rate and what makes the pre-period and post-period asymptotically independent, which is the engine behind fs-PDA’s sample-splitting inference and the two-term HAC variance in l2 / lasso.

A4 (Sample-size regime). \(N \to \infty\), \(T_0 = T_0(N) \to \infty\) deterministically with \(\log N / T_0 \to 0\), \(T_2 \to \infty\) with \(\log N / T_2 \to 0\). \(N\) may exceed \(T_0\), which is the entire point of the high-dimensional PDA literature. Li-Bell’s A7 additionally posits \(\eta = \lim T_2 / T_0 \in [0, \infty)\), which determines whether the first-stage variance term \(\widehat\Sigma_1\) matters.

A5 (Donor pool regularity). The controls’ Gram matrix has enough variation:

  • For lasso (Li-Bell A2): \(\mathrm{Rank}(\widetilde B) = K\) – removing the first row of the loading matrix leaves full-rank factor variation; \(E[x_t x_t']\) is invertible on the active set.

  • For fs (Shi-Huang A1): a sparse Riesz / restricted eigenvalue condition – the minimum eigenvalue of the population Gram matrix over any \(u\)-unit subset (\(u \le (1 + \delta_1) R\)) is bounded below. The paper shows this is a natural implication of the latent factor model, not an ad-hoc lasso-style assumption.

  • For l2 (Shi-Wang A1-A2): factor strength \(\xi_N = \phi_{\min}(\boldsymbol\Lambda' \boldsymbol\Lambda / N)\) may vanish (weak factors allowed); the idiosyncratic covariance has eigenvalues bounded in \([\underline\sigma^2, \overline\sigma^2]\).

A6 (Variant-specific structure of \(\boldsymbol\beta^0\) ).

  • lasso: sparse \(\boldsymbol\beta^0\) – only \(m = o(T_0)\) of its components are non-zero.

  • l2: dense \(\boldsymbol\beta^0\) – almost no exact zeros (the factor projection gives every donor a small-but-nonzero coefficient).

  • fs: agnostic – the inference is valid uniformly over a class of DGPs that includes both dense and sparse \(\boldsymbol\beta^0\) (Theorem 1 in Shi-Huang).

A7 (Inferential regularity). For all three, the post-period average effect \(\widehat\tau\) has a CLT with HAC long-run variance consistently estimable by Newey-West. For l2 and lasso, both the pre-period (first-stage) and post-period HAC variances enter; for fs, sample-splitting absorbs the first-stage term and only the post-period HAC variance enters. Shi & Huang apply the same sample-splitting argument to their modified-BIC LASSO, which is why lrvar_lag drops the first-stage term there too.

When the assumptions bind: practical diagnostics#

  1. Factor-driven DGP (A1). PDA’s whole identification story rides on the latent factor structure. If the panel is not well-described by a small number of common factors, the linear-projection equation has a non-vanishing \(\epsilon_t\) term that the high-dimensional estimators cannot remove.

    Plausibly violated when donors are largely idiosyncratic (each follows its own unrelated process), or when one or two donors have a structural break that the factor model can’t absorb. Diagnostic: run an SVD on the donor pre-period matrix; the top few singular values should carry the bulk of the spectral energy. If the spectrum is flat-tailed (no clear factor cutoff), the factor model fails and PDA’s linear-projection consistency is fragile. In that regime, use a balancing-aware estimator (MicroSynth (User-Level Balancing SC) if you have unit-level data) or stay with canonical SC.

  2. Single treated unit, absorbing aggregate-level treatment (A2). Multiple treated units, treatment that turns off, or interference among donors break the framework.

    Plausibly violated when the policy is rescinded mid- sample, or when treated and donor states are spatially or economically linked enough that the donors’ untreated trajectories shift. Diagnostic: the config validator enforces single-cohort; the silent failure is treated-donor spillover. Split donors by geographic / economic distance to the treated unit and refit; large ATE shifts flag interference. Use Spillover-Aware Synthetic Control (SPILLSYNTH) or Spatial Synthetic Difference-in-Differences (SpSyDiD) for genuine spillovers, FECT / Synthetic Difference-in-Differences (SDID) for staggered designs.

  3. Weak temporal dependence (A3). All three variants assume mixing or \(\rho\)-mixing pre-period series with geometric decay. Unit-root outcomes, long-memory series, or series with structural breaks fail this.

    Plausibly violated when the outcome is a price level, a cumulative quantity, or an undifferenced macroeconomic series. Diagnostic: ADF / KPSS on the pre-period residuals; non-stationarity flags A3 failure. The pre/post asymptotic-independence story (which licenses fs-PDA’s sample-splitting inference) is then in question. First- difference the outcome, or use Synthetic Business Cycle (SBC) (a stationary- cycle estimator) before PDA.

  4. Sample-size regime (A4). PDA needs both \(T_0\) and \(T_2\) growing with \(\log N\) small relative to each. A short post-period (\(T_2 \le 5\)) breaks the CLT on \(\widehat\tau\); a short pre-period (\(T_0 \le 20\)) breaks the moment-convergence rates.

    Plausibly violated when the pre-period is short with many donors. Diagnostic: compute \((\log N) / T_0\) and \((\log N) / T_2\); both should be visibly below 1. If they are not, the asymptotic approximation has not kicked in. Either lengthen the panel (aggregate to a finer time grid), prune donors, or move to canonical SCM / Two-Step Synthetic Control / Forward Difference-in-Differences (FDID) which work with shorter panels.

  5. Donor regularity (A5). Each variant has its own Gram-matrix / factor-strength condition. The practical common failure is near-collinear donors: two donor series that move together up to noise produce a near- singular pre-period Gram matrix.

    Plausibly violated when the donor pool contains near-duplicates (two adjacent states with essentially identical industry mix). Diagnostic: read the condition number of \(\Gamma_{\mathcal T_1}(\mathbf x_t, \mathbf x_t')\). A condition number above ~1e6 is a red flag. For lasso and fs this manifests as selection flipping between near-clones across seeds; for l2 the \(\varepsilon\)-validation curve gets noisy. Prune one of each clone pair before refitting.

  6. Coefficient structure (A6) – choosing the right variant. The biggest practitioner-side decision is whether to assume sparse or dense \(\boldsymbol\beta^0\). Choosing wrong pays a real cost: lasso on a dense truth over-selects and inflates size (see the Path-B table above: LASSO’s size is 0.16-0.36 under the dense factor DGP, vs fs’s 0.05); l2 on a sparse truth pays variance for the dense fit it doesn’t need.

    Diagnostic: fit fs first – it’s valid in both regimes per Shi-Huang Theorem 1, and the selected \(\widehat R\) and per-step \(R^2\) curve tell you whether you’re in a sparse (few donors carry the fit) or dense (many donors add information) regime. Then run the matched variant (lasso if fs keeps a handful; l2 if fs keeps many).

  7. Inferential regularity (A7). The HAC long-run variance must be consistently estimable. With strong serial correlation and a short post-period, the Bartlett / Newey-West kernel needs more lags than the post-period supports.

    Plausibly violated when \(T_2 \le 8\) and the treatment-effect series is autocorrelated. Diagnostic: plot the autocorrelation function of res.gap[-T2:]; if it stays high beyond \(\sqrt{T_2}\) lags, the Newey-West bandwidth choice is binding and the CI is optimistic. Lengthen the post-window if you can, or report bootstrap CIs alongside the HAC ones.

When to use PDA – and when not to#

Reach for PDA when:

  • You have a single treated unit, a moderate-to-large donor pool (\(N\) comparable to or exceeding \(T_0\)), and a plausibly factor-driven panel. PDA was designed for exactly this regime, and unlike canonical SCM, the projection has no simplex / non-negativity constraint – it can extrapolate through negative coefficients on far donors when the factor structure demands it.

  • You want HAC-based, classical-statistics inference on the ATE with a closed-form normal-distribution test, not a permutation or conformal procedure. PDA’s CLT-based inference is what makes it the closest synthetic-control cousin to difference-in-differences from an inferential standpoint.

  • The treated unit’s pre-trajectory lies in the linear span (not necessarily convex hull) of the controls, so a no-constraint linear projection makes sense. PDA cannot recover an effect when the projection itself is impossible.

  • You’re between dense (l2) and sparse (lasso) regimes and want a uniformly valid test that doesn’t require choosing the right sparsity story – run fs.

Do not use PDA when:

  • You need convex (non-negative, sum-to-one) weights as a policy-interpretation deliverable. PDA’s no-constraint projection produces negative coefficients on far donors, which is awkward to explain in many policy contexts. Use canonical SCM / Two-Step Synthetic Control (canonical SC) or Forward-Selected Synthetic Control (FSCM) (forward-selected SC with the simplex retained).

  • The treated unit is structurally outside the donor span (not just the convex hull). PDA’s linear projection cannot reach a treated outcome that no linear combination of donor outcomes can express. The pre-period RMSE stays large at every PDA variant. Use Imperfect Synthetic Controls (ISCM), whose A2(b) mechanism identifies the effect through donors that use the treated unit as a positive-weight donor in their synthetic controls.

  • Outcomes are non-stationary (unit-root or trending series). A3 fails and the pre/post asymptotic-independence story breaks. First-difference the outcome (the l2-relaxation paper’s empirical PPI application does exactly this), or use Synthetic Business Cycle (SBC) (stationary-cycle estimator).

  • You have multiple treated units with overlapping cohorts. PDA’s theorems (with the exception of the l2 relaxerm which does support multiple treated units but is not written yet) are written for the single-treated case. Use Synthetic Difference-in-Differences (SDID) for staggered adoption.

  • Spillovers across donors. A2’s no-interference clause fails when donor states are economically linked to the treated state. Use Spillover-Aware Synthetic Control (SPILLSYNTH) or Spatial Synthetic Difference-in-Differences (SpSyDiD).

  • Continuous or multi-valued treatment. PDA encodes a single binary intervention; continuous dose belongs in Continuous-Treatment Synthetic Control (CTSC).

  • Distributional questions (Lorenz curves, QTEs). PDA targets the mean ATE through a Gaussian-likelihood linear projection. Use Distributional Synthetic Control (DSC) for distributional effects.

  • You need Bayesian posterior credible bands. PDA returns frequentist HAC-based CIs. For Bayesian inference and posterior inclusion probabilities on donors, use Bayesian Synthetic Control with a Soft Simplex Constraint (BVS-SS) (spike-and-slab with a soft simplex).

  • Very short pre-period \((T_0 \le 15)\) with many donors. The high-dimensional approximation has not kicked in; the selected \(\widehat\beta\) is noise. Use canonical SCM / Two-Step Synthetic Control / Forward Difference-in-Differences (FDID), which work without high-dimensional asymptotics.

  • Very short post-period \((T_2 \le 5)\). The CLT on \(\widehat\tau\) is shaky; the HAC bandwidth choice dominates the inference. Either accept a wider permutation CI from canonical SCM / Two-Step Synthetic Control, or move to the l2-relaxation multiple-treated-units extension (Shi-Wang Section 4.4) which is built for this regime.

  • You want predictor-level matching (covariates + pre-period outcomes), not outcome-only projection. PDA’s workhorse projection is on donor outcomes, not on predictor moments. Use canonical SCM / Two-Step Synthetic Control / Sparse Synthetic Control (SparseSC) (predictor selection with L1 penalty on the V-weight matrix) for the predictor-matching setup.

  • The factor model itself is the object of interest (you want to identify and interpret the factors). PDA is agnostic to factor estimation – the factor model only motivates the linear projection, never enters the estimator. Use Factor Model Approach (FMA) (factor-model-aware estimator) if recovering factors is the goal.

Empirical Illustration: Hong Kong economic integration#

The original HCW [HCW] application – and Shi & Huang’s Example 1 – evaluates the effect of economic integration with mainland China on Hong Kong’s quarterly real-GDP growth, using 24 comparison economies. Here all four PDA methods run on the same data, and the package returns the time-varying effect, the ATE, and a HAC confidence interval for each.

import pandas as pd
from mlsynth import PDA

url = "https://raw.githubusercontent.com/jgreathouse9/mlsynth/refs/heads/main/basedata/HongKong.csv"
df = pd.read_csv(url)

res = PDA({"df": df, "outcome": "GDP", "treat": "Integration",
           "unitid": "Country", "time": "Time",
           "methods": ["hcw", "l2", "LASSO", "fs"], "alpha": 0.05,
           "display_graphs": True}).fit()

for name, fit in res.fits.items():
    print(f"{name:6s} ATE {fit.att:.4f}  SE {fit.att_se:.4f}  "
          f"95% CI ({fit.ci[0]:.4f}, {fit.ci[1]:.4f})  p={fit.p_value:.3f}  "
          f"donors={len(fit.donor_weights)}")

This prints:

hcw    ATE 0.0403  SE 0.0057  95% CI (0.0292, 0.0514)  p=0.000  donors=6
l2     ATE 0.0261  SE 0.0033  95% CI (0.0195, 0.0326)  p=0.000  donors=24
lasso  ATE 0.0330  SE 0.0054  95% CI (0.0224, 0.0436)  p=0.000  donors=11
fs     ATE 0.0395  SE 0.0059  95% CI (0.0280, 0.0510)  p=0.000  donors=9

All four find a significant positive integration effect on Hong Kong’s GDP growth – between +2.6 and +4.0 percentage points per quarter – differing only in how they choose controls. hcw runs the exact best-subset search and certifies a parsimonious six-economy model (Austria, Italy, Korea, Mexico, Norway, Singapore): on this pool the long 44-quarter pre-period gives the branch-and-bound room to certify the global optimum (certified_optimal is True, gap 0) even over 24 donors. l2 keeps all 24 controls with dense, signed coefficients (pre-RMSE 0.012); lasso keeps 11; fs grows to 9. The four estimates bracket the Forward-DiD result on the same data (0.025), a useful cross-method check.

Prediction intervals#

The HAC confidence interval above quantifies uncertainty in the average treatment effect. For uncertainty in each period’s effect, set prediction_intervals=True to attach the bootstrap prediction intervals of Jiang, Li, Shen and Zhou [pdapi] to every fitted variant. These bound the post-period untreated counterfactual \(Y_t\) (and hence the effect \(\Delta_t = y_t - \widehat Y_t\)), combining the in-sample estimation error with the out-of-sample prediction error that a confidence interval for the mean omits. The construction (their Algorithm 2.1) resamples the pre-period prediction error with a dependent wild bootstrap and the post-period error with a residual bootstrap, refits the chosen estimator on each bootstrap sample at the fixed tuning parameter, and reads quantiles of the self-normalized statistic \(\widehat e_t / \sqrt{\widehat V_t + \widehat\sigma^2}\).

The implementation lives at the shared mlsynth.utils.inferutils.pda_prediction_intervals() so any panel-data estimator can reuse it. The pre-period error is resampled with the dependent wild bootstrap of their Algorithm 2.1 – Bartlett-correlated multipliers whose dependence range is a bandwidth in \(T_0\), so a persistent error is resampled as a persistent one. pi_dependent=False switches to the ordinary i.i.d. multipliers of their Remark 2.2, which is cheaper and valid only when the errors are independent to begin with; the choice is recorded on the result, since a band built under each is not the same number. The correction is modest and shows up on average rather than on every panel – over eight simulated panels the dependent scheme gave the wider band on five to eight of them, with a mean width ratio of 1.015 under white noise and 1.043 at \(\rho = 0.9\). Persistence is what makes it matter, which is why the paper’s algorithm is the default. Both the equal-tailed (eq) and symmetric (sy) intervals are returned, and each variant reports which studentization it used: sandwich for the post-selection OLS HAC variance \(\widehat V_t\) (hcw, lasso and fs, which all select then run OLS – hcw is exactly the low-dimensional post-selection-OLS case of Jiang et al.’s Remark 2.1, with best subset as the selector re-run on each bootstrap draw), or the sigma2 fallback when that sandwich is undefined – as for the dense L2-relaxation when the controls outnumber the pre-periods.

res = PDA({"df": df, "outcome": "GDP", "treat": "Integration",
           "unitid": "Country", "time": "Time",
           "methods": ["l2", "LASSO", "fs"],
           "prediction_intervals": True, "pi_n_boot": 199, "pi_seed": 0,
           "display_graphs": False}).fit()

for name, fit in res.fits.items():
    eff = fit.prediction_intervals["effect"]
    print(name, fit.prediction_intervals["studentization"])
    for k in range(3):                       # first three post-quarters
        lo, hi = eff["eq_lower"][k], eff["eq_upper"][k]
        print(f"  t+{k+1}: effect {eff['point'][k]:+.4f}  95% PI ({lo:+.4f}, {hi:+.4f})")

The pointwise 95% effect intervals for the first three post-quarters (decimal GDP growth):

method  studentization   t+1                          t+2                          t+3
l2      sandwich         +0.0203 (-0.0128, +0.0411)   +0.0427 (+0.0076, +0.0658)   +0.0023 (-0.0347, +0.0272)
lasso   sandwich         +0.0312 (-0.0066, +0.0499)   +0.0519 (+0.0165, +0.0706)   +0.0152 (-0.0198, +0.0397)
fs      sandwich         +0.0249 (-0.0079, +0.0521)   +0.0467 (+0.0158, +0.0719)   +0.0103 (-0.0237, +0.0351)

Each band is wider than the ATE confidence interval, because it carries the out-of-sample prediction error on top of the estimation error, and it tightens or widens quarter by quarter as the fitted controls track each period better or worse.

The cumulative effect#

The intervals above bound one period at a time. The number an event study is usually quoted by is the running total – how much the treated unit gained over the first \(L\) periods – and cumulative_band=True attaches a band for it:

res = PDA({..., "prediction_intervals": True, "cumulative_band": True}).fit()
band = res.fits["lasso"].cumulative_band
for L in (1, 4, 8):
    i = L - 1
    print(f"L={L}: {band.point[i]:+.3f}  ({band.lower[i]:+.3f}, {band.upper[i]:+.3f})")

An interval for a running total is not the running total of the period intervals, and the two obvious shortcuts are both wrong. Adding the period endpoints treats every period’s error as moving in lockstep, so the width grows in proportion to \(L\) whatever the data does. Rescaling a single period’s interval by \(\sqrt{L}\) assumes the opposite, that the errors are independent, and for a donor fit the estimation error persists across horizons, so that one is wrong as well. Neither measures anything.

What mlsynth does instead is accumulate each bootstrap replicate’s error path first and take the standard error afterwards. Whatever correlation the period errors have is then carried into the band rather than assumed into it: independent errors widen it like \(\sqrt{L}\), perfectly correlated ones like \(L\), and the replicates decide which. On the Oregon opioid panel of Wheeler’s LassoSynth – 13 post-periods, one treated state – the standard error grows by a factor of 4.43, against \(\sqrt{13} = 3.61\) for independence and \(13\) for lockstep. It sits between them, which is the whole point of measuring it. The resulting half-width is 1.37 where summing the period endpoints would have given 3.78, against a cumulative point estimate of 7.59.

The band is simultaneous over horizons rather than pointwise. A cumulative path is read as a path – “positive by period six and never back” is a claim about every horizon at once – and a pointwise band read that way covers at well below its nominal level. One shared critical value (mlsynth.utils.supt.supt_critical_value(), following Montiel Olea and Plagborg-Moller) restores the level for the path as a whole; on the Oregon panel it is 2.54 where the pointwise normal quantile would be 1.96.

The multiplier is referred to the law of the statistic it is a quantile of. The sup-t construction divides each horizon error by a standard error, and if that standard error were the true one the ratio would be normal. It is estimated from the same replicates, so the ratio is a Student-t, and its maximum sits wider than the normal law says – by more as the ensemble shrinks. supt_critical_value simulates the ratio in full, drawing the errors and their estimated variances jointly, so the multiplier reaches \(1 - \alpha\) at any ensemble size and not only asymptotically. See Partially Pooled SCM (PPSCM) for the construction; the two estimators share the function. reference="normal" restores the older behaviour for a caller reproducing a number from an earlier release.

By default the band reuses the replicate paths the prediction-interval bootstrap already produced, so it costs no extra refits, and on that setting it requires prediction_intervals=True. Asking for it without the bootstrap raises rather than returning an empty field, since a caller reading a missing band as an absent effect is the one failure worth ruling out. PPSCM’s cumulative_band is the same object built the same way, sharing mlsynth.utils.supt, so the two estimators cannot drift apart in what the phrase means.

Resampling the calibration errors#

Reusing the bootstrap’s paths is free only once the bootstrap has run, and the bootstrap is the expensive part: pi_n_boot refits of the whole selection, 999 at the default. cumulative_method="resample" builds the same band from a rolling-origin calibration pass instead – one refit per origin, roughly ten at the panel lengths PDA is used on – and needs no bootstrap at all:

res = PDA({..., "cumulative_band": True, "cumulative_method": "resample"}).fit()
band = res.fits["lasso"].cumulative_band
band.method            # "resample"

The construction is Andrew Wheeler’s, from his LassoSynth post: take out-of-sample conformity scores, draw from them, accumulate the draws, and read the band off the accumulated paths. mlsynth generalises it in one respect. Wheeler draws one score per post period independently, which assumes the period errors are uncorrelated. The variance of an \(L\)-period total is

\[L\gamma_0 + 2\sum_{k=1}^{L-1} (L-k)\gamma_k,\]

so positive autocorrelation makes the total more variable than \(L\) independent draws imply, and an independent draw is too narrow by a factor that grows with the horizon. mlsynth therefore draws whole blocks of consecutive errors, flipping each block’s sign to symmetrise – which is Wheeler’s mirrored pool generalised from a period to a block, and coincides with it exactly at cumulative_block=1. cumulative_block=0, the default, uses the whole horizon; cumulative_n_sim sets how many paths are drawn, and unlike pi_n_boot those cost no refits.

How long a block the calibration series can support is settled by an identity, not by taste. The series is centred, so the circular sum over a \(b\)-block is minus the sum over the complementary \((n-b)\)-block the two partition it into; their spreads are exactly equal, and the drawn spread is symmetric about \(b = n/2\). Past the midpoint a longer block draws a narrower total, mirroring a shorter one, and at \(b = n\) every path sums to zero and the band has no width. The draw refuses past \(n/2\), since block length has stopped meaning how much serial correlation is carried. With \(m\) rolling origins the series is \(m \times L\) periods, so a whole-horizon block asks for \(m \geq 2\) and a block of \(b\) asks for \(m \geq 2L/b\).

Short of that midpoint the same constraint costs spread instead of meaning, and the draw corrects for it. Since the centred series sums to zero its circular autocovariances do too, so a \(b\)-block carries

\[\operatorname{Var}(S_b) = \sum_{|k|<b} (b-|k|)\,\hat\gamma_k = b\,v\left(1 - \frac{b-1}{n-1}\right),\]

and the drawn totals come out narrow by \(\sqrt{(n-b)/(n-1)}\) – sixteen percent for a thirteen-period block drawn from forty-seven calibration periods. The draw multiplies by the inverse. The factor is exactly one at \(b = 1\), so the single-period construction and the reference parity pinned on it are unchanged, and it is exact for a horizon made of whole blocks, which the default \(b = L\) always is.

What the correction does not repair is the attenuation of the sample autocovariances themselves. A short calibration series understates persistence, and a scalar factor cannot recover it, so a band drawn from few windows still runs narrow on a strongly persistent panel. More rolling origins is the only remedy.

The level, and the fluctuation about it#

A cumulative band has a second term, and it is the larger one. The total over \(L\) periods is \(L\) times the mean error over those periods, so what drives it is the calibration window’s level, not the fluctuation about that level. Drawn from one flat series the level is invisible: every block shares it, so it contributes nothing to their spread, and centring removes it outright. Drawn from \(m\) windows laid end to end the level is present but diluted, since a block of length \(L\) usually straddles a boundary and averages two windows’ levels.

So the draw separates them. Each path takes one window’s level, sign-flipped like everything else and held across the whole horizon, and blocks of the within-window residuals on top of it. The window means are deviations from the grand mean and carry \(m - 1\) degrees of freedom, so they are scaled by \(\sqrt{m/(m-1)}\) before being drawn from. Because each window’s residuals now sum to zero, the zero-sum constraint binds at the window length instead of the series length, and the block is capped at half a window and corrected against it.

The level is shrunk before it is drawn from. The \(m\) window means scatter even when every window shares a level, since each is an average of \(L\) noisy periods, so their variance estimates \(\sigma^2_{\text{level}} + \sigma^2_{\text{within}}/L\). Drawing from them whole charges the band for a level that may not be there – on a series with none it inflates the total by about 1.40 at any number of windows, the spurious level variance and the fluctuation variance being equal by construction. So the noise floor is subtracted, giving the one-way random-effects estimator

\[\hat\sigma^2_{\text{level}} = \max\left(0,\ s^2_{\text{between}} - s^2_{\text{within}}/L\right),\]

which leaves a strongly levelled series almost untouched. The floor is not free: truncating the negative side of an estimator whose mean is zero biases it up, so on a level-free series the total still runs about 1.12 times wide at six windows, falling to 1.04 at forty. More windows is what buys that back.

Measured on panels built from real market data – a long pre-period, a 13-period horizon, a treated unit the donors can reproduce – the realised coverage of the total moves from 0.85 to 0.94 for VanillaSC and from 0.72 to 0.94 for a blank-window design, against a nominal 0.95. PDA reads 0.98 on the same panels, and that is its band working as specified and not conservatism: its cumulative band is simultaneous over the whole horizon path, so any single horizon is covered at more than \(1-\alpha\) by construction.

Where the scores come from differs from Wheeler as well, and the difference has a direction. He calibrates on leave-one-out residuals: each is scored by a model that saw every pre-period point but one, so it measures interpolation. mlsynth calibrates on rolling origins, each scored by a model trained only on what came before it, over a window of exactly the reported horizon. That is the harder question and gives the larger errors, so the resampled band runs wider than his – about 1.4 times on the benchmark panel. The two calibration sets are not interchangeable for a cumulative horizon.

The choice does not change what comes back. The same PDACumulativeBand is returned, built by the same simultaneous machinery, with only its method field recording which construction produced it. One reader serves all four PDA variants, since it asks the estimator for its counterfactual instead of a weight vector, which LASSO’s intercept and the modified-BIC path’s donor scaling would otherwise complicate and which forward selection and HCW do not expose at all.

Verification (reference implementation). The durable case benchmarks/cases/pda_wheeler_lassosynth.py runs Wheeler’s construction and mlsynth’s on one shared score vector and pins that they agree at block=1 to four tenths of a percent of band width, which is Monte Carlo noise on 200,000 draws. It measures that from horizon two, because at horizon one the band is a quantile of \(2m\) discrete atoms and both implementations land exactly on one; the case records that those atoms are adjacent, so the difference there is discreteness and not disagreement. It also records the 1.4 width ratio above, and that a whole-horizon block widens the band by 1.58 on an AR(0.7) panel, which is the generalisation doing its work. The AR(1) closed form for those eight periods is 1.96; three rolling origins give a 24-period calibration series, and the sample autocovariances of 24 points understate the persistence, so the drawn band does not reach it.

hcw produces these same intervals, with one practical caveat: the bootstrap refits the entire selection on every draw, and HCW’s refit re-runs the best-subset search. On the 24-economy pool that is roughly ten seconds a draw, so its prediction intervals there cost minutes – while the certified point estimate and the HAC ATE interval need no resampling and return at once. On HCW’s intended, pre-screened pool (the ten candidate economies of the sovereignty study) the search is tiny and the intervals come straight back:

cands = ["China", "Indonesia", "Japan", "Korea", "Malaysia", "Philippines",
         "Singapore", "Taiwan", "Thailand", "United States"]
sub = df[df["Country"].isin(["Hong Kong"] + cands)]

hk = PDA({"df": sub, "outcome": "GDP", "treat": "Integration",
          "unitid": "Country", "time": "Time", "method": "hcw",
          "prediction_intervals": True, "pi_n_boot": 199,
          "display_graphs": False}).fit()
eff = hk.fits["hcw"].prediction_intervals["effect"]
lo, hi = eff["eq_lower"][0], eff["eq_upper"][0]
print(f"t+1: effect {eff['point'][0]:+.4f}  95% PI ({lo:+.4f}, {hi:+.4f})")
# t+1: effect +0.0304  95% PI (-0.0227, +0.0703)

Verification#

Note

Empirical (Path A, Hong Kong). All four PDA methods run on the HCW Hong Kong panel (above) and agree on a significant positive integration effect, consistent with the literature and the Forward-DiD cross-check (0.025).

Original HCW (Path A, best subset). benchmarks/cases/pda_hcw_hongkong.py reproduces Hsiao, Ching & Wan (2012) Tables XVI-XVII value-for-value with method="hcw": on the sovereignty study (ten candidate economies, T0 = 18), AICc selects {Japan, Korea, Taiwan, USA} with the published OLS weights, pre-period \(R^2 = 0.9314\), and an insignificant average effect of -3.96% – cross-validating against the pampe R package.

Prediction intervals (Path B, coverage). The bootstrap prediction intervals are validated by benchmarks/cases/pda_pi_coverage.py, which reproduces the coverage geometry of Jiang et al. (2025) Tables 2-5 on their Setup 1: the equal-tailed and symmetric intervals cover near the nominal 95%, while the normal-quantile intervals under-cover (to about 77% under exponential errors).

Table 1 in full (Path B). All 108 cells of Shi & Huang’s Monte Carlo are reproduced by benchmarks/cases/fspda_table1.py, against the paper and against their own FS.R and lasso.BIC.R. Details: fsPDA — Shi & Huang (2023) Table 1.

Random forest (Path A in the reference, distributional in the port). benchmarks/cases/rfpda_watches.py runs method="rf" on Shi & Huang’s luxury-watch panel against Liu, Long & Luo (2025) Section 5.2. Their own RF.R reproduces their published -2.66%, R-squared 0.78, seven controls and p value 0.063 exactly; the port is held to the distribution that estimate is a draw from, and to the West long-run variance, which agrees with their HAC_function to 0.07% on the test statistic. Details: rfPDA — Liu, Long and Luo (2025) luxury watches.

Simulation study (Path B): forward selection vs LASSO#

Shi & Huang’s (2023) Table 1 compares forward selection against LASSO on a four-factor DGP, ported from their released FS.simulation.dense.R into mlsynth.utils.pda_helpers.simulation.simulate_pda_panel(): four factors (f1 i.i.d.; f2 AR(1) 0.9; f3 MA(2) (0.8,0.4); f4 ARMA(1,1) (0.5,0.5) under the dynamic structure; under the i.i.d. structure factor \(\ell\) is N(0, \ell^2), so the fourth carries sixteen times the variance of the first); loadings U(1,2) on the treated + 4 relevant controls and U(-0.5,0.5) on the remaining 96; idiosyncratic N(0, 0.5^2); one treated unit, \(N=100\) controls, \(T_0=T_2\). Shocks D1-D7 set the post-period ATE (D1-D3 null -> size; D4-D7 non-zero -> power).

The irrelevant loadings are the detail that decides the design. Section 4.1 of the paper gives them as U(-0.1,0.1); the loading.RData their driver loads has them five times wider, and that is what Table 1 was run on. At the wider range the 96 irrelevant donors carry real signal, the regression is dense, and no method can select its way to a sparse truth – which is the paper’s subject.

The full table, all 108 cells, is the fspda_table1 case. Driving the packaged PDA at its defaults (LassoCV for the penalty, Li & Bell’s two-component variance for the test) at \(T_0=100\), with 200 replications for size and 60 for power:

mlsynth’s defaults on the Table-1 design, \(T_0=100\)#

factors

method

# donors

size (D1)

power (D5)

i.i.d.

fs

5.5

0.095

1.00

i.i.d.

LASSO

13.5

0.070

1.00

dynamic

fs

0.095

1.00

dynamic

LASSO

0.045

1.00

Forward selection is the parsimonious rule in both structures and its test is sized at 0.095 under either, against the paper’s 0.059 and 0.088. The cross-validated LASSO takes in 13.5 donors where the paper’s modified BIC takes 11.

The paper’s size inflation does not appear here, and the reason is the penalty rule. Shi & Huang report the LASSO’s null rejection rate going from 0.058 under i.i.d. factors to 0.184 under dynamic ones. Holding the variance estimator fixed at Li & Bell’s and changing only the penalty reproduces the split: under the modified BIC the rate goes 0.013 to 0.087 at this length, and under cross-validation it goes 0.070 to 0.045. The inflation belongs to their selection rule, not to L1 selection. Both rules are fully powered at D5 (mean-1 shift). Durable cases: fspda_table1 for the paper’s table, pda_table1 for the defaults.

Note

The LASSO cells above are cross-validated; the paper’s are not. Shi & Huang select the Lasso penalty with a modified BIC (Remark 4 cont., p.521: “we tune the constants in the modified BIC to allow Lasso to take in more variables”); mlsynth’s L1-PDA defaults to LassoCV (5-fold cross-validation). Their rule is lasso_criterion="mbic" (see Choosing lambda above), and pairing it with lrvar_lag gives their test as well. Under both, fspda_table1 reproduces Table 1 cell by cell; the table above is what the defaults do on the same design.

The panel-level comparison against their code is a third case: fspda_dense_mc runs PDA on panels generated by their own FS.simulation.dense.R and compares to what their FS() and lasso.BIC() return on those same panels.

Cross-validated against fsPDA on their own panels

fspda_dense_mc is the cell-level check. On eight panels from their dense Monte Carlo (T1 = T2 = 50, 100 donors, four factors), forward selection picks the same donors on every one, with coefficients, ATE, pre-period R-squared and t-statistic agreeing to about \(10^{-13}\).

Their third column, the simplex-constrained synthetic control, is covered by the same case through VanillaSC: the two attain the same optimum of scm.R’s program, agreeing on the objective to \(10^{-11}\) and on the selected donors on every panel.

The sparse half of their simulation/ directory is fspda_sparse_mc, which runs their fs(), lasso_ic() and oracle() on the three sparse DGPs. Those are deliberately different rules from the ones mlsynth implements – their sparse forward selection searches all donors at each step and scores var(e), and their LASSO criterion uses a different residual variance and a different penalty grid – so that case pins agreement rates and error ratios instead of digits. Forward selection lands on the identical donor set on 28 of 30 panels regardless, within 5.4 percent on out-of-sample RMSE.

The LASSO under lasso_criterion="mbic" agrees on the selected donors and the selected penalty on all eight panels when their lasso.BIC is run with glmnet converged, with coefficients to \(2\times10^{-5}\). Against their function as published it agrees on five of eight. The difference is glmnet’s default thresh = 1e-7, which stops short in this \(p = 100\), \(n = 50\) design: mlsynth’s coefficients attain a lower value of the LASSO objective than glmnet’s do, and because the criterion scores those coefficients, an under-converged fit can hand a different grid point the minimum. The benchmark records both runs so the two claims stay separable.

The fs_intercept knob – valid size on factor data

Achieving the correct fs size above required a fix. The released fsPDA R package (est.fsPDA.R) fits the donor regression with an intercept; on the paper’s mean-zero factor DGP that intercept absorbs a spurious pre-period constant which extrapolates into the post window, biasing the gap and inflating the null rejection rate to ~0.20. The paper’s Table 1 was produced by the simulation code (FS.R), which fits without an intercept and yields valid size. mlsynth exposes both via PDAConfig.fs_intercept (default False = the no-intercept, valid-size form; set True for panels with genuine unit level shifts). With the default, the fs D1 rejection rate drops from ~0.20 (intercept) to the ~0.05-0.09 reported above (no intercept).

One honest caveat: under dynamic factors fs shows mild residual size inflation at small \(T\) (the “imprecise long-run-variance” effect the paper itself notes), shrinking toward 5% as \(T_0 \to \infty\).

L2-relaxation (Shi & Wang). The l2 method’s out-of-sample MPSE falls with \(T\) and its test approaches the nominal 5% size as \(T_0 \to \infty\), matching Shi & Wang’s Table 2 (size \(0.142\) at \(T_0=50\) → \(0.072\) at \(200\)). Each fit cross-validates \(\varepsilon\) over its own grid, which is what makes a large Monte Carlo costly here: at the 100 donors this study uses, one fit on the default grid takes about a second at \(T_0 = 50\), against 5 s before the ranking sweep was separated from the reported fit (see the note on solving the grid above). The case runs a coarse twelve-point grid and summarizes the table, so the full sweep stays out of the test suite.

Multiple treated units#

When several units are treated by the same intervention, Shi & Wang’s L2-relaxation PDA fits a counterfactual per treated unit against the shared control pool and aggregates the effects into a per-period cross-sectional ATE,

\[\widehat{\mathrm{ATE}}_t = \frac{1}{J} \sum_{j=1}^{J} \bigl( y_{jt} - \widehat{y}_{jt} \bigr), \qquad \mathrm{s.e.} = \frac{\sqrt{\mathbf{1}'\widehat{\Sigma}_e\,\mathbf{1}}}{J},\]

with \(\widehat{\Sigma}_e\) the cross-sectional covariance of the pre-period prediction residuals (so the standard error is constant across post-periods). mlsynth.utils.pda_helpers.multitreat.run_pda_multitreat() implements this. Because every per-unit fit shares the same \(\widehat{\boldsymbol{\Sigma}} = X'X/T_0\), all \(J\) fits run through a single OSQP factorisation – the batched solver mlsynth.utils.pda_helpers.l2.batch.l2_relax_batch() updates only the constraint bounds per (unit, tau) (hundreds of conic solves become hundreds of warm-started ADMM updates). On the Brexit study (52 UK firms vs 300 controls) this reproduces the paper’s first-day return ATE of \(-4.3\%\) (\(t \approx -7.4\)); see benchmarks/cases/pda_brexit.py.

Core API#

Panel Data Approach (PDA) for program evaluation.

A thin, NumPy-first orchestration over mlsynth.utils.pda_helpers. PDA (Hsiao, Ching & Wan 2012) predicts a single treated unit’s untreated counterfactual by a linear regression on the control units fit over the pre-treatment window, then extrapolates out-of-sample to estimate the ATE. Four variants are supported, each with the inference theory from its own paper:

  • hcw – the original best-subset PDA (Hsiao, Ching & Wan 2012): unrestricted OLS (with intercept) on the best subset of controls, the subset chosen by AICc (also AIC / BIC); HAC t-test on the ATE. Matches the pampe R package and HCW Table XVI value-for-value.

  • l2 – L2-relaxation (Shi & Wang 2024): dense ridge-like coefficients via min ||beta||_2^2 s.t. ||eta_hat - Sigma_hat beta||_inf <= tau; ATE inference combines pre-residual and post-effect HAC long-run variances.

  • LASSO – L1 (Li & Bell 2017): sparse donor selection by cross-validated LASSO; HAC t-test on the ATE with a first-stage variance term.

  • fs – forward selection (Shi & Huang 2023): greedy R^2 selection with a modified-BIC stopping rule; post-selection HAC t-test (sample splitting). The scalable descendant of hcw’s combinatorial search.

Set method for one variant or methods to run several at once.

class mlsynth.estimators.pda.PDA(config: PDAConfig | dict)#

Bases: object

Panel Data Approach estimator (l2 / LASSO / fs).

Parameters:

config (PDAConfig or dict) – Validated configuration. Beyond the common fields, PDA reads method / methods (which variant(s) to run), tau (the l2 relaxation parameter; None selects it by validation), and alpha (CI level).

References

Hsiao, C., Ching, H. S., & Wan, S. K. (2012). A panel data approach for program evaluation. Journal of Applied Econometrics, 27(5), 705-740.

Shi, Z., & Wang, Y. (2024). L2-relaxation for Economic Prediction.

Li, K. T., & Bell, D. R. (2017). Estimation of average treatment effects with panel data. Journal of Econometrics, 197(1), 65-75.

Shi, Z., & Huang, J. (2023). Forward-selected panel data approach for program evaluation. Journal of Econometrics, 234(2), 512-535.

fit() → PDAResults#

Run the requested PDA variant(s) and return typed results.

Returns:

PDAResults – Container of per-variant PDAMethodFit objects (coefficients, counterfactual, gap, ATE, HAC standard error, CI, p-value, donor weights), with convenience aliases (att, att_se, counterfactual, donor_weights) forwarding to the primary variant.

Configuration#

class mlsynth.config_models.PDAConfig(*, df: ~pandas.DataFrame, outcome: str, treat: str, unitid: str, time: str, display_graphs: bool = True, save: bool | str = False, counterfactual_color: ~typing.List[str] = <factory>, treated_color: str = 'black', plot: ~mlsynth.config_models.PlotConfig = <factory>, method: ~typing.Annotated[str, _PydanticGeneralMetadata(pattern='^(LASSO|l2|fs|hcw|rf)$')] = 'fs', methods: ~typing.List[str] | None = None, hcw_criterion: ~typing.Annotated[str, _PydanticGeneralMetadata(pattern='^(AICc|AIC|BIC)$')] = 'AICc', hcw_nvmax: ~typing.Annotated[int | None, ~annotated_types.Gt(gt=0)] = None, hcw_holdout: ~typing.Annotated[int | None, ~annotated_types.Gt(gt=0)] = None, hcw_backend: ~typing.Annotated[str, _PydanticGeneralMetadata(pattern='^(fw|scip)$')] = 'fw', tau: float | None = None, alpha: ~typing.Annotated[float, ~annotated_types.Gt(gt=0.0), ~annotated_types.Lt(lt=1.0)] = 0.05, lasso_criterion: ~typing.Annotated[str, _PydanticGeneralMetadata(pattern='^(cv|mbic)$')] = 'cv', lasso_mbic_const: ~typing.Annotated[float, ~annotated_types.Gt(gt=0)] = 2.0, fs_intercept: bool = False, lrvar_lag: int | None = None, rf_split: ~typing.Literal['temporal', 'random'] = 'temporal', rf_train_fraction: ~typing.Annotated[float, ~annotated_types.Gt(gt=0.0), ~annotated_types.Lt(lt=1.0)] = 0.6, rf_validation_fraction: ~typing.Annotated[float, ~annotated_types.Gt(gt=0.0), ~annotated_types.Lt(lt=1.0)] = 0.2, rf_n_estimators: ~typing.Annotated[int, ~annotated_types.Gt(gt=0)] = 500, rf_max_depth: ~typing.Annotated[int | None, ~annotated_types.Gt(gt=0)] = None, rf_mtry: ~typing.Annotated[int | None, ~annotated_types.Gt(gt=0)] = None, rf_k_max: ~typing.Annotated[int | None, ~annotated_types.Ge(ge=2)] = None, rf_importance: ~typing.Literal['permutation', 'oob'] = 'permutation', rf_seed: int = 0, rf_n_seeds: ~typing.Annotated[int, ~annotated_types.Ge(ge=1)] = 1, l2_standardize: bool = True, prediction_intervals: bool = False, pi_n_boot: ~typing.Annotated[int, ~annotated_types.Ge(ge=2)] = 999, pi_seed: int | None = 0, pi_dependent: bool = True, cumulative_band: bool = False, cumulative_method: ~typing.Literal['bootstrap', 'resample'] = 'bootstrap', cumulative_block: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 0, cumulative_n_sim: ~typing.Annotated[int, ~annotated_types.Ge(ge=2)] = 2000)#

Configuration for the Panel Data Approach (PDA) estimator.

alpha: float#
cumulative_band: bool#
cumulative_block: int#
cumulative_method: Literal['bootstrap', 'resample']#
cumulative_n_sim: int#
fs_intercept: bool#
hcw_backend: str#
hcw_criterion: str#
hcw_holdout: int | None#
hcw_nvmax: int | None#
l2_standardize: bool#
lasso_criterion: str#
lasso_mbic_const: float#
lrvar_lag: int | None#
method: str#
methods: List[str] | None#
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

pi_dependent: bool#
pi_n_boot: int#
pi_seed: int | None#
prediction_intervals: bool#
rf_importance: Literal['permutation', 'oob']#
rf_k_max: int | None#
rf_max_depth: int | None#
rf_mtry: int | None#
rf_n_estimators: int#
rf_n_seeds: int#
rf_seed: int#
rf_split: Literal['temporal', 'random']#
rf_train_fraction: float#
rf_validation_fraction: float#
tau: float | None#

Result Containers#

PDA.fit() returns a PDAResults, whose fits maps each variant to a PDAMethodFit (coefficients, intercept, counterfactual, gap, ATE, HAC standard error, CI, p-value, donor weights, and the selected-donor list for lasso/fs). The prepared, NumPy-only panel is exposed as a PDAInputs, with units and time addressed through an IndexSet.

Note

PDA.fit() returns an EffectResult on the standardized two-family contract. It is a dispatcher over the variants in res.fits (l2 / lasso / fs); the selected variant drives the flat accessors (res.att / res.att_ci / res.counterfactual / res.gap / res.donor_weights / res.pre_rmse), which resolve through the standardized sub-models. res.donor_weights are the regression coefficients (PDA is a regression counterfactual, not a simplex average); res.att_by_method() / res.se_by_method() report every variant.

Frozen, NumPy-first containers for the Panel Data Approach (PDA).

PDA (Hsiao, Ching & Wan 2012) predicts a treated unit’s untreated counterfactual by a linear regression on the control units fit over the pre-treatment window, then extrapolates out-of-sample. mlsynth exposes several high-dimensional PDA variants, each in its own subpackage with the inference theory from its own paper:

  • l2 – L2-relaxation (Shi & Wang 2024).

  • lasso – L1/LASSO (Li & Bell 2017).

  • fs – forward-selected PDA (Shi & Huang 2023).

  • hcw – original best-subset PDA (Hsiao, Ching & Wan 2012).

  • rf – random-forest donor selection (Liu, Long & Luo 2025).

Everything below is pure NumPy; units/time are addressed through IndexSet. The only DataFrame touchpoint is setup.

class mlsynth.utils.pda_helpers.structures.PDACumulativeBand(horizons: ndarray, point: ndarray, lower: ndarray, upper: ndarray, se: ndarray, critical_value: float, alpha: float, n_replicates: int, method: str)#

Bases: object

Simultaneous band for the cumulative (running-total) effect path.

lower[L] and upper[L] bound the total effect over horizons 0..L, and the band covers every L at once with probability 1 - alpha, so a statement about the path is covered at the level it claims.

se is the standard error of the running total at each horizon, taken from the replicate paths themselves – which is what makes the band’s growth an observation rather than an assumption: independent period errors grow it like sqrt(L), perfectly correlated ones like L, and the replicates carry whichever is true.

alpha: float#
critical_value: float#
horizons: ndarray#
lower: ndarray#
method: str#
n_replicates: int#
point: ndarray#
se: ndarray#
upper: ndarray#
class mlsynth.utils.pda_helpers.structures.PDAHoldout(horizon: int, min_train: int, origins: ndarray, errors: ndarray, held_out_rmse: float, in_sample_rmse: float, ratio: float, n_origins: int)#

Bases: object

Rolling-origin holdout error for a pre-period fit.

ratio is the summary: held-out root mean squared error over in-sample. Near one, the fit extrapolates about as well as it interpolates. Much above one, the donor coefficients are chasing the pre-period, and the post-period counterfactual rests on a relation the data has not tested.

errors are per period in time order, horizon of them per origin, each from a refit that never saw the period it scores.

errors: ndarray#
held_out_rmse: float#
horizon: int#
in_sample_rmse: float#
min_train: int#
n_origins: int#
origins: ndarray#
ratio: float#
class mlsynth.utils.pda_helpers.structures.PDAInputs(unit_index: ~mlsynth.utils.fast_scm_helpers.structure.IndexSet, time_index: ~mlsynth.utils.fast_scm_helpers.structure.IndexSet, y: ~numpy.ndarray, X: ~numpy.ndarray, T0: int, treated_label: ~typing.Any, metadata: ~typing.Dict[str, ~typing.Any] = <factory>)#

Bases: object

Preprocessed, NumPy-only panel for the PDA engine.

Parameters:
  • unit_index (IndexSet) – All N donor units (column order of X).

  • time_index (IndexSet) – All T periods (row order of y and X).

  • y (np.ndarray) – Treated-unit outcome over all periods, shape (T,).

  • X (np.ndarray) – Donor outcomes, shape (T, N).

  • T0 (int) – Number of pre-treatment periods (T1); post is T2 = T - T0.

  • treated_label (Any) – Identifier of the treated unit.

  • metadata (dict) – Free-form provenance.

property T: int#
T0: int#
property T2: int#
X: ndarray#
property donor_labels: ndarray#
metadata: Dict[str, Any]#
property n_donors: int#
time_index: IndexSet#
treated_label: Any#
unit_index: IndexSet#
y: ndarray#
class mlsynth.utils.pda_helpers.structures.PDAMethodFit(name: str, beta: ~numpy.ndarray, intercept: float, counterfactual: ~numpy.ndarray, gap: ~numpy.ndarray, att: float, att_se: float, ci: ~typing.Tuple[float, float], p_value: float, donor_weights: ~typing.Dict[~typing.Any, float], selected_donors: ~typing.List[~typing.Any] | None = None, prediction_intervals: ~typing.Dict[str, ~typing.Any] | None = None, cumulative_band: ~mlsynth.utils.pda_helpers.structures.PDACumulativeBand | None = None, holdout: ~mlsynth.utils.pda_helpers.structures.PDAHoldout | None = None, metadata: ~typing.Dict[str, ~typing.Any] = <factory>)#

Bases: object

A single PDA-variant fit (l2 / lasso / fs).

att: float#
att_se: float#
beta: ndarray#
ci: Tuple[float, float]#
counterfactual: ndarray#
cumulative_band: PDACumulativeBand | None = None#
donor_weights: Dict[Any, float]#
gap: ndarray#
holdout: PDAHoldout | None = None#
intercept: float#
metadata: Dict[str, Any]#
name: str#
p_value: float#
prediction_intervals: Dict[str, Any] | None = None#
selected_donors: List[Any] | None = None#
class mlsynth.utils.pda_helpers.structures.PDAResults(*, effects: ~mlsynth.config_models.EffectsResults | None = None, fit_diagnostics: ~mlsynth.config_models.FitDiagnosticsResults | None = None, time_series: ~mlsynth.config_models.TimeSeriesResults | None = None, weights: ~mlsynth.config_models.WeightsResults | None = None, inference: ~mlsynth.config_models.InferenceResults | None = None, method_details: ~mlsynth.config_models.MethodDetailsResults | None = None, sub_method_results: ~typing.Dict[str, ~typing.Any] | None = None, additional_outputs: ~typing.Dict[str, ~typing.Any] | None = None, raw_results: ~typing.Dict[str, ~typing.Any] | None = None, execution_summary: ~typing.Dict[str, ~typing.Any] | None = None, plot_config: ~mlsynth.config_models.PlotConfig | None = None, inputs: ~mlsynth.utils.pda_helpers.structures.PDAInputs, fits: ~typing.Dict[str, ~mlsynth.utils.pda_helpers.structures.PDAMethodFit], selected_variant: str = 'fs', metadata: ~typing.Dict[str, ~typing.Any] = <factory>)#

Bases: BaseEstimatorResults

Top-level container returned by mlsynth.PDA.fit().

An EffectResult (the observational report): a dispatcher over the PDA variants in fits, it lifts the selected variant’s quantities into the standardized sub-models so the flat accessors (att / att_ci / counterfactual / gap / donor_weights / pre_rmse) resolve through the base contract. donor_weights here are the regression coefficients (PDA is a regression/factor counterfactual, not a simplex donor average). The PDA-specific fields keep every variant fit.

Parameters:
  • inputs (PDAInputs) – Preprocessed panel.

  • fits (dict) – {variant_name: PDAMethodFit} for every variant run (l2 / lasso / fs).

  • selected_variant (str) – Which variant drives the standardized surface / flat accessors.

att_by_method() → Dict[str, float]#
property att_se: float#
fits: Dict[str, PDAMethodFit]#
inputs: PDAInputs#
metadata: Dict[str, Any]#
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True, 'json_encoders': {<class 'numpy.ndarray'>: <function BaseEstimatorResults.Config.<lambda>>}}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

se_by_method() → Dict[str, float]#
selected_variant: str#

Helper Modules#

Data preparation – the only DataFrame touchpoint: pivots to NumPy, builds the unit/time IndexSetes, and splits pre/post.

Long-DataFrame -> NumPy boundary for PDA (the only pandas touchpoint).

mlsynth.utils.pda_helpers.setup.derive_treatment(df: DataFrame, unitid: str, time: str, treat: str) → Tuple[Any, Any]#

Read the single treated unit and its first treated period from treat.

mlsynth.utils.pda_helpers.setup.prepare_pda_inputs(df: DataFrame, *, unitid: str, time: str, outcome: str, treat: str) → PDAInputs#

Pivot the panel to NumPy, build IndexSets, split pre/post.

Returns:

PDAInputs – Pure-NumPy container: treated vector y (T,), donor matrix X (T, N), T0, and unit/time IndexSets.

Shared HAC long-run-variance machinery (Bartlett/Newey-West) and the N(0,1) test used by every PDA variant.

Shared HAC long-run-variance machinery for PDA inference.

All three PDA variants base inference on a heteroskedasticity- and autocorrelation-consistent (HAC) long-run variance of a scalar time series of post-period treatment effects (and, for some variants, pre-period prediction residuals). The Bartlett/Newey-West and uniform kernels are provided; the default truncation lag follows Newey-West.

mlsynth.utils.pda_helpers.inference.cumulative_supt_band(effect_path, error_paths, *, alpha: float = 0.05, n_sims: int = 200000, seed=0, method: str = 'bootstrap')#

Simultaneous band for the running total, from the bootstrap’s own paths.

The counterpart of mlsynth.utils.ppscm_helpers.inference.cumulative_supt_band() for PDA, sharing mlsynth.utils.supt so the two estimators cannot drift apart in what “cumulative band” means.

An interval for a cumulative effect is not the running total of the per-period intervals. Adding endpoints treats the period errors as moving in lockstep, so the width grows like L whatever the data does; rescaling one period’s interval by sqrt(L) assumes they are independent. Here each replicate’s error path is accumulated first and the standard error taken after, so the correlation the errors actually have is the correlation the band inherits.

The band is simultaneous over horizons, because a cumulative path is read as a path – “positive by period six and never back” is a statement about all of them at once, which a pointwise band does not cover at its nominal level.

Parameters:
  • effect_path (array-like, shape (H,)) – The per-period effect from the full fit; the band centres on its cumsum.

  • error_paths (array-like, shape (B, H)) – One post-period prediction-error path per bootstrap replicate, as returned in error_paths by mlsynth.utils.inferutils.pda_prediction_intervals(). Rows holding a non-finite entry are dropped, so a draw whose refit failed is absent rather than counted as a zero that would shrink the band.

  • alpha (float, default 0.05) – The band is simultaneous at 1 - alpha.

  • n_sims, seed – Tabulation of the sup-t critical value.

  • method (str, default “bootstrap”) – Recorded on the result; PDA’s replicates are bootstrap draws, already on the estimator’s scale, so no delete-one inflation is applied.

Returns:

PDACumulativeBand

mlsynth.utils.pda_helpers.inference.fspda_lrvar_lag(T2: int, lrvar_lag: int | None = None) → int#

Bartlett-kernel truncation lag for the fsPDA long-run variance.

Follows Shi & Huang’s released fsPDA package (est.fsPDA): the default is floor(T2 ** (1/4)) and a user-supplied lag must be a non-negative integer no larger than floor(sqrt(T2)).

mlsynth.utils.pda_helpers.inference.hac_lrv(z: ndarray, lag: int | None = None, kernel: str = 'bartlett') → float#

HAC long-run variance of a mean-zero-able scalar series z.

lrv = gamma_0 + sum_{l=1}^{L} k(l) * 2 * gamma_l with gamma_l the sample autocovariance and k the Bartlett (1 - l/(L+1)) or uniform kernel. The series is de-meaned first.

Every autocovariance divides by n, including the lagged ones, which have only n - l products to sum. This is R’s acf(type = "covariance") and the Newey-West convention, so the fixed-lag branch reproduces the released fsPDA package; dividing the lag-l term by n - l instead inflates it by n / (n - l) and costs the sequence its positive semi-definiteness, which is what makes the weighted sum a variance in the first place.

mlsynth.utils.pda_helpers.inference.lrvar_prewhite_nw(x: ndarray) → float#

Prewhitened Newey-West long-run variance of the mean of x.

Andrews-Monahan (1992) VAR(1) prewhitening + a Bartlett kernel with the Newey-West (1994) data-driven bandwidth + the finite-sample adjustment – i.e. R’s sandwich::lrvar(x, type = "Newey-West", prewhite = TRUE, adjust = TRUE), which Shi & Huang use for the post-selection t-test in their applications (app1_luxury_watch/fsPDA.R). Returns the variance of the sample mean (so the t-statistic is mean(x) / sqrt(lrvar_prewhite_nw(x))).

Prewhitening is what makes this differ sharply from the plain Bartlett estimator on strongly serially-dependent effects (e.g. monthly growth rates, which mean-revert): the VAR(1) step removes the bulk of the dependence before the kernel smooths the remainder, then the long-run factor 1 / (1 - A) recolors it.

mlsynth.utils.pda_helpers.inference.newey_west_lag(n: int) → int#

Newey-West (1994) automatic truncation lag floor(4 (n/100)^(2/9)).

mlsynth.utils.pda_helpers.inference.normal_test(att: float, se: float, alpha: float = 0.05)#

Two-sided N(0,1) test: returns (p_value, (ci_lower, ci_upper)).

L2-relaxation (Shi & Wang): the relaxation primal, \(\varepsilon\) validation, and the two-term HAC ATE inference.

L2-relaxation estimation (Shi & Wang 2024).

Solves the L2-relaxation primal (their Eq. 3)

min_beta (1/2) ||beta||_2^2 s.t. || eta_hat - Sigma_hat beta ||_inf <= tau,

with Sigma_hat = X'X / T1 and eta_hat = X'y / T1 over the pre-period.

Following the authors’ released L2relax (ishwang1/L2relax-PDA), the treated and control series are standardised (demeaned and scaled to unit variance) before forming Sigma / eta, and the solution is mapped back to the original scale: beta = sd_y * (beta_tilde / sd_X) and intercept alpha = mean_y - mean_X . beta. Standardisation is the default (it is what the replication code does and what reproduces the paper’s empirical results); set standardize=False for the raw-scale variant. The tuning parameter tau is chosen by out-of-sample validation over a log-spaced grid (the optimal tau is often a tiny fraction of max|eta|).

mlsynth.utils.pda_helpers.l2.estimation.cross_validate_tau(y_pre: ndarray, X_pre: ndarray, val_frac: float = 0.2, n_coarse: int = 40, n_fine: int = 40, standardize: bool = True, tau_grid: ndarray | None = None) → float#

Validate tau by sequential out-of-sample validation on the tail.

The training window is split in time order – fit on the earlier 1 - val_frac fraction, validate on the most-recent val_frac tail – so no future period informs an earlier counterfactual (unlike a K-fold split over contiguous blocks, which trains on both past and future of each fold). tau_grid overrides the automatic log-spaced grid (e.g. to match a reference grid); otherwise the grid is log-spaced up to max|eta| (the optimal tau is often a tiny fraction of that).

mlsynth.utils.pda_helpers.l2.estimation.fit_l2(y: ndarray, X: ndarray, T0: int, tau: float | None = None, standardize: bool = True, tau_grid: ndarray | None = None) → Tuple[ndarray, float, ndarray, float]#

Fit L2-relaxation; return (beta, intercept, counterfactual, tau).

mlsynth.utils.pda_helpers.l2.estimation.l2_relax(y_pre: ndarray, X_pre: ndarray, tau: float, standardize: bool = True) → Tuple[ndarray, float]#

Solve the L2-relaxation primal for coefficients and intercept.

The primal objective ||beta||^2 / 2 is strictly convex, so the solution is unique (Shi & Wang 2024, Lemma 2). It is solved natively with polished OSQP (mlsynth.utils.pda_helpers.l2.batch.l2_relax_solve()) – the same solver the multiple-treated batch uses – which matches an interior-point (cvxpy/CLARABEL) solve on the unique optimum without cvxpy’s per-call canonicalisation overhead.

ATE inference for L2-relaxation PDA (Shi & Wang 2024, Theorem 3).

Single treated unit. With the post-period estimated effects Delta_hat_t = y_t - y_hat_t (t in T2) and the pre-period prediction residuals e_t = y_t - y_hat_t (t in T1), the ATE Delta_bar is asymptotically normal,

Z_hat = Delta_bar / sqrt( rho_hat_(1)^2 / T1 + rho_hat_(2)^2 / T2 ) -> N(0, 1),

where rho_hat_(1)^2 is the HAC long-run variance of the pre-period residuals and rho_hat_(2)^2 is the HAC long-run variance of the de-meaned post-period effects. Both estimation uncertainty (pre) and post-period noise contribute.

The kernel is Bartlett; Theorem 3 states the estimator with the uniform kernel, an unweighted two-sided sum sum_{l=-h}^{h}, which the authors adopt “for simplicity” while noting the result “is compatible with the Bartlett kernel (Newey & West 1987)”. The substitution is theirs to sanction and it is not free: on Hong Kong it moves the t-statistic from 7.69 to 7.83. Bartlett is what makes the estimate non-negative without a clamp, which is why it is the default here.

The autocovariances divide by the length of the index set, matching the paper’s E_S(x_t) = |S|^{-1} sum_{t in S} x_t. The truncation lag is Newey & West (1994), which is the rule the paper points to.

mlsynth.utils.pda_helpers.l2.inference.l2_ate_inference(y: ndarray, counterfactual: ndarray, T0: int, alpha: float = 0.05) → Tuple[float, float, Tuple[float, float], float]#

Return (att, se, ci, p_value) for the L2-relaxation ATE.

LASSO (Li & Bell): cross-validated L1 estimation and the HAC t-test with a first-stage variance term.

L1/LASSO PDA estimation (Li & Bell 2017).

Selects control units and estimates coefficients by LASSO on the pre-period, with the penalty chosen by cross-validation, then predicts the treated unit’s counterfactual out-of-sample.

mlsynth.utils.pda_helpers.lasso.estimation.MBIC_CONST = 2.0#

The constant H in the modified BIC; lasso.BIC’s default.

mlsynth.utils.pda_helpers.lasso.estimation.MBIC_GRID = array([0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 , 0.11,        0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 , 0.21, 0.22,        0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 , 0.31, 0.32, 0.33,        0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 , 0.41, 0.42, 0.43, 0.44,        0.45, 0.46, 0.47, 0.48, 0.49, 0.5 , 0.51, 0.52, 0.53, 0.54, 0.55,        0.56, 0.57, 0.58, 0.59, 0.6 , 0.61, 0.62, 0.63, 0.64, 0.65, 0.66,        0.67, 0.68, 0.69, 0.7 , 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77,        0.78, 0.79, 0.8 , 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88,        0.89, 0.9 , 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99,        1.  ])#

The penalty grid lasso.BIC searches (seq(0.01, 1, by = 0.01)).

mlsynth.utils.pda_helpers.lasso.estimation.fit_lasso(y: ndarray, X: ndarray, T0: int, cv: int = 5, random_state: int = 0, alpha: float | None = None, intercept: bool = True, standardize: bool = False) → Tuple[ndarray, float, ndarray, ndarray]#

Fit LASSO PDA; return (beta, intercept, counterfactual, support_mask).

alpha fixes the penalty (skipping cross-validation); None (default) selects it by LassoCV. The fixed-penalty path is used by the prediction-interval bootstrap, which reuses lambda_{T0}.

intercept defaults to True, the cross-validated path’s convention. standardize scales the donors the way glmnet does before penalising them and returns coefficients on the original scale; it is off by default and on for Shi and Huang’s rule. Their call is glmnet(..., standardize = TRUE, intercept = FALSE), so lasso_mbic_alpha() pairs with intercept=False, standardize=True – the penalty and the criterion have to see the same fit.

mlsynth.utils.pda_helpers.lasso.estimation.lasso_cv_alpha(y: ndarray, X: ndarray, T0: int, cv: int = 5, random_state: int = 0) → float#

The cross-validated LASSO penalty for the pre-period (the alpha_ that fit_lasso() selects).

Exposed so the prediction-interval bootstrap can refit at a fixed penalty (Jiang et al. 2025 reuse lambda_{T0} across bootstrap samples rather than re-cross-validating each one).

mlsynth.utils.pda_helpers.lasso.estimation.lasso_mbic_alpha(y: ndarray, X: ndarray, T0: int, *, const: float = 2.0, grid: ndarray | None = None) → float#

The penalty Shi and Huang’s modified BIC selects on the pre-period.

Reproduces fsPDA’s lasso.BIC: fit the LASSO path without an intercept, score each penalty by mbic_criterion(), and keep the minimiser. Pair it with fit_lasso(..., intercept=False), which is the convention their glmnet call uses.

Parameters:
  • const (float) – H in the criterion. Their default is 2; the paper describes tuning it “to allow Lasso to take in more variables”, and raising it selects fewer donors.

  • grid (np.ndarray, optional) – Penalties to search. Defaults to MBIC_GRID, their seq(0.01, 1, by = 0.01).

Raises:

MlsynthConfigError – If const is not positive, T0 is not positive, or the grid is empty or contains a non-positive penalty.

mlsynth.utils.pda_helpers.lasso.estimation.mbic_criterion(y: ndarray, X: ndarray, T0: int, alpha: float, const: float = 2.0) → float#

Shi and Huang’s modified BIC at one penalty.

log(sigma^2) + const * log(log N) * log(T0) / T0 * k, with sigma^2 the pre-period mean squared residual and k the number of selected donors.

ATE inference for LASSO PDA (Li & Bell 2017, Theorem 3.2).

The test statistic is sqrt(T2) * Delta_bar / sqrt(Sigma_hat) with Sigma_hat = Sigma_hat_1 + Sigma_hat_2:

  • Sigma_hat_2 – the HAC (Newey-West) long-run variance of the post-period effects, the always-present post-period averaging variance;

  • Sigma_hat_1 – the first-stage (pre-period estimation) variance, here the OLS prediction variance of the mean post-period counterfactual on the LASSO-selected support. Li & Bell note it is negligible when T1 >> T2.

Equivalently the ATE standard error is SE = sqrt(var_firststage + Sigma_hat_2 / T2).

Supplying lrvar_lag asks for a different paper’s test. Shi & Huang’s fsPDA studentizes by the post-period long-run variance alone, at a truncation lag the caller fixes – Z = ATE / sqrt(lrvar(d, h) / T2) in their lasso.BIC – with no first-stage term. The two conventions are far apart when T1 is comparable to T2: on their Table 1 design the first-stage term is 44-46% of the total variance, so Li & Bell’s standard error runs about a third larger and the test under-rejects against their cells.

mlsynth.utils.pda_helpers.lasso.inference.lasso_ate_inference(y: ndarray, X: ndarray, counterfactual: ndarray, support: ndarray, T0: int, alpha: float = 0.05, lrvar_lag: int | None = None) → Tuple[float, float, Tuple[float, float], float]#

Return (att, se, ci, p_value) for the LASSO PDA ATE.

Parameters:

lrvar_lag (int, optional) – None (default) gives Li & Bell’s two-component variance. An integer gives the released fsPDA package’s t-test: a Bartlett long-run variance of the post-period effects at that truncation lag, and nothing else. It must be a non-negative integer no larger than floor(sqrt(T2)).

Raises:

ValueError – If lrvar_lag is negative or above that cap.

Forward selection (Shi & Huang): greedy R^2 selection with modified-BIC stopping and the post-selection HAC t-test.

Forward-selected PDA estimation (Shi & Huang 2023).

Greedy forward selection of control units: at each step add the donor whose inclusion maximizes the pre-treatment OLS R^2 (equivalently minimizes the residual variance sigma^2 = mean(e^2)). Selection stops as soon as the modified information criterion

IC(r) = log( sigma^2(U_r) ) + B * r, B = log(log N) * log(T1) / T1

stops decreasing (the stopping rule of Wang, Li & Tsai used in the authors’ fsPDA R package), starting from the intercept-only IC = log(var(y1)). The counterfactual is the OLS extrapolation on the selected set. This is a direct port of est.fsPDA.R.

Scoring the step without refitting#

Written as defined, each step refits OLS once per remaining donor and keeps the smallest sigma^2: N least-squares solves per step, and the run costs O(N T1 r^2) for r selected donors. The step’s answer is available in one matrix-vector product. Let r_vec = y1 - P y1 be the pre-period residual on the donors already selected (P the projection onto their span, including the constant when one is fitted) and z_j = x_j - P x_j donor j orthogonalised against that span. Adding j drops the residual sum of squares by

gain_j = (z_j’ r_vec)^2 / ||z_j||^2 = (x_j’ r_vec)^2 / ||z_j||^2,

the second equality because r_vec is already orthogonal to the selected span. Minimising sigma^2 over the pool is maximising gain_j over it, so Z' r_vec ranks every candidate at once and a rank-one downdate of Z carries the orthogonalisation into the next step. The cost per step falls to O(T1 N), and the donor pool no longer multiplies the number of solves.

The ranking is exact in exact arithmetic, so it decides the step; the step’s sigma^2 still comes from _ols_sigma2() on the winning design, which is what the IC reads and what stops the search. Candidates whose scores sit within rounding of the leader – duplicated donors, a donor already inside the selected span – are all refit and compared the way the scan compares them, so the search selects what the definition selects and stops where the definition stops.

The two part company only where the step has no answer to give. A donor pool can contain donors that fit the pre-period identically – exact duplicates, or a pool of rank one, where every donor is a multiple of the same series – and a fit that has interpolated (y1 exactly in the donor span) puts every remaining donor in that position, since the residual has fallen to ~1e-16 and log(sigma^2) keeps the search going. Inside such a set the scan’s winner is whichever candidate its least-squares solve rounded smallest, so reproducing it means running the scan. What holds is that the two agree on the donors that explain the outcome and on the counterfactual to machine precision: the members of an equivalent set are interchangeable, and the extras an interpolating fit collects carry coefficients at the 1e-16 level. How many extras it collects is not a property of either rule – once sigma^2 is at 1e-31 the accept test compares a ratio of rounding artefacts against exp(-B), so the step count there follows the BLAS, for the scan as much as for this search. Below _SHORTLIST_MAX equivalent donors the exact comparison settles the tie the same way the scan settles it.

mlsynth.utils.pda_helpers.fs.estimation.forward_select(y: ndarray, X: ndarray, T0: int, intercept: bool = False) → Tuple[List[int], ndarray, float, ndarray]#

Forward-select donors with the stop-on-increase IC rule, then refit OLS.

Returns (selected_indices, beta_full, intercept, counterfactual) where beta_full is an N-vector with zeros off the selected support.

Selection is capped at T0 - 1 - intercept donors so the pre-period fit keeps a residual degree of freedom; see the comment on max_selected.

Parameters:

intercept (bool, default False) – When False the donor regression is fit without a constant and the IC baseline is log(mean(y_pre**2)) – the paper’s simulation convention (Shi & Huang 2023, simulation/FS.R). This is the correctly-specified form for the factor DGP (mean-zero factors, no unit level shift) and yields valid test size. When True a constant is included and the baseline is log(var(y_pre)) – the released fsPDA R package convention (est.fsPDA.R), appropriate for panels with genuine level differences but size-distorting on centered data.

Post-selection ATE inference for forward-selected PDA (Shi & Huang 2023, Eq. 4).

Because forward selection uses pre-treatment data only and the pre/post periods become asymptotically independent under weak dependence, the naive conditional t-statistic is valid:

Z_U = Delta_bar / sqrt(lrvar_hat) -> N(0, 1),

where lrvar_hat is the long-run variance of the sample mean of the (de-meaned) post-period treatment effects. By default mlsynth uses the prewhitened Newey-West estimator (sandwich::lrvar(..., prewhite = TRUE, adjust = TRUE)) that Shi & Huang use in their applications (app1_luxury_watch/fsPDA.R); on serially-dependent effects this is far less conservative than a plain Bartlett kernel. Supplying lrvar_lag instead switches to the released est.fsPDA package’s fixed-lag Bartlett estimator (floor(T2 ** (1/4)) if the cap, see fspda_lrvar_lag()).

mlsynth.utils.pda_helpers.fs.inference.fs_ate_inference(y: ndarray, counterfactual: ndarray, T0: int, alpha: float = 0.05, lrvar_lag: int | None = None) → Tuple[float, float, Tuple[float, float], float]#

Return (att, se, ci, p_value) for the forward-selected PDA ATE.

Run loop assembling the per-variant fits.

Run the requested PDA variant(s) and assemble typed per-method fits.

mlsynth.utils.pda_helpers.orchestration.resolve_methods(method: str, methods: List[str] | None) → List[str]#

Internal method keys to run (explicit methods win over method).

mlsynth.utils.pda_helpers.orchestration.run_pda(inputs: PDAInputs, methods: List[str], tau: float | None, alpha: float, fs_intercept: bool = False, lrvar_lag: int | None = None, l2_standardize: bool = True, l2_tau_grid: Sequence[float] | None = None, lasso_criterion: str = 'cv', lasso_mbic_const: float = 2.0, hcw_criterion: str = 'AICc', hcw_nvmax: int | None = None, hcw_backend: str = 'fw', hcw_holdout: int | None = None, rf_kwargs: Dict[str, Any] | None = None, prediction_intervals: bool = False, cumulative_band: bool = False, pi_n_boot: int = 999, pi_dependent: bool = True, pi_seed: int | None = 0, cumulative_method: str = 'bootstrap', cumulative_block: int = 0, cumulative_n_sim: int = 2000) → Dict[str, PDAMethodFit]#

Fit each requested PDA variant with its own paper’s inference.

When prediction_intervals is set, Jiang et al. (2025) bootstrap prediction intervals (per-period treatment effect and counterfactual) are attached to each variant via mlsynth.utils.inferutils.pda_prediction_intervals().