
Fast Interactive Fixed Effects (IFE) for Generalized Synthetic Control
Source:R/RcppExports.R
gsc_ife_cpp.RdImplements Xu (2017) IFE model with optional covariate adjustment and optional additive fixed effects (Xu 2017, Remark 3). When X_co has p > 0 slices, alternates the two steps of Bai (2009): factors: truncated SVD of Y_tilde = Y_co - X_co * beta beta: inverse(sum_i X_i' M_F X_i) sum_i X_i' M_F Y_i, with the loadings concentrated out through the annihilator M_F of the factors When X_co has 0 slices (default), falls back to the plain 3-step estimator. Additive effects are swept out of the control panel by the within transformation first; on a balanced panel this solves the joint least squares problem exactly, and the effects are recovered from the means of the residual.
Usage
gsc_ife_cpp(
Y_co,
Y_tr_pre,
r,
X_co,
X_tr_pre,
max_iter = 1000L,
tol = 1e-08,
force = "none"
)Arguments
- Y_co
Control units outcome matrix (T x N_co)
- Y_tr_pre
Treated units pre-treatment outcomes (T_pre x N_tr)
- r
Number of latent factors (must be <= min(T, N_co)); 0 is allowed with additive effects
- X_co
Time-varying covariate cube (T x N_co x p). Pass an empty cube (0 slices) for the covariate-free estimator.
- X_tr_pre
Time-varying covariate cube for treated units in the pre-treatment window (T_pre x N_tr x p). Required for correct Step 2 loading estimation per Xu (2017): lambda_hat is estimated from Y_tr_pre - X_tr_pre * beta (covariate- demeaned). Pass an empty cube (0 slices) to skip demeaning (backward-compatible, but biased when beta != 0).
- max_iter
Maximum iterations of the covariate loop (default 1000)
- tol
Convergence tolerance on relative beta change (default 1e-8)
- force
Additive fixed effects:
"none"(default),"unit","time"or"two-way".
Value
A list with components:
F: estimated time factors (T x r).L_co: control-unit factor loadings (N_co x r).L_tr: treated-unit factor loadings (N_tr x r).Y_tr_hat: estimated treated-unit counterfactual outcomes (T x N_tr), additive effects included, covariate contribution excluded.Y_co_hat: fitted control outcomes on the same basis (T x N_co).singular_values: singular values from the final truncated SVD.beta: estimated covariate coefficients (p x 1), empty when no covariates are supplied.mu,alpha_co,alpha_tr,xi: grand mean, unit effects of the control and treated units, and time effects (zero whereforceleaves them out).n_iter: iterations of the covariate loop (0 without covariates).converged: whether the covariate loop mettolwithinmax_iter(alwaysTRUEwithout covariates).