% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{gsc_ife_cpp}
\alias{gsc_ife_cpp}
\title{Fast Interactive Fixed Effects (IFE) for Generalized Synthetic Control}
\usage{
gsc_ife_cpp(Y_co, Y_tr_pre, r, X_co, X_tr_pre, max_iter = 50L, tol = 1e-06)
}
\arguments{
\item{Y_co}{Control units outcome matrix (T x N_co)}

\item{Y_tr_pre}{Treated units pre-treatment outcomes (T_pre x N_tr)}

\item{r}{Number of latent factors (must be <= min(T, N_co))}

\item{X_co}{Time-varying covariate cube (T x N_co x p). Pass an empty
cube (0 slices) for the covariate-free estimator.}

\item{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).}

\item{max_iter}{Maximum EM iterations (default 50)}

\item{tol}{Convergence tolerance on relative beta change (default 1e-6)}
}
\value{
A list with components:
\itemize{
\item \code{F}: estimated time factors (T x r).
\item \code{L_co}: control-unit factor loadings (N_co x r).
\item \code{L_tr}: treated-unit factor loadings (N_tr x r).
\item \code{Y_tr_hat}: estimated treated-unit counterfactual outcomes (T x N_tr).
\item \code{singular_values}: singular values from the final truncated SVD.
\item \code{beta}: estimated covariate coefficients (p x 1), empty when no
covariates are supplied.
}
}
\description{
Implements Xu (2017) IFE model with optional covariate adjustment.
When X_co has p > 0 slices, runs an EM loop alternating between:
E-step: truncated SVD of Y_tilde = Y_co - X_co * beta
M-step: panel OLS to update beta given current factors
When X_co has 0 slices (default), falls back to the plain 3-step estimator.
}
