% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ife.R
\name{.ife_fit}
\alias{.ife_fit}
\title{Core IFE Estimation via SVD-Based Alternating Projections}
\usage{
.ife_fit(Y_dm, X_dm, r, tol = 1e-09, max_iter = 10000L, method = "static")
}
\arguments{
\item{Y_dm}{T x N demeaned outcome}

\item{X_dm}{T x N x p demeaned covariate array (or NULL if p = 0)}

\item{r}{integer, number of factors (>= 0)}

\item{tol}{convergence tolerance on max |beta_new - beta_old|}

\item{max_iter}{maximum iterations}

\item{method}{character: "static" (Bai 2009) or "dynamic" (Moon and Weidner 2017)}
}
\value{
list:
beta       p x 1 coefficient vector (numeric(0) if p = 0)
F_hat      T x r factor matrix  (normalized F'F/T = I_r)
Lambda_hat N x r loading matrix
X_tilde    T x N x p factor-projected covariates (for SE computation)
e_mat      T x N residual matrix E = Y_dm - X_dm * beta - F Lambda'
n_iter     number of iterations used
converged  logical
}
\description{
Estimates the Interactive Fixed Effects model by iterating
between an OLS step for the regression coefficients (given current factor
estimates) and an SVD step for the factor matrix (given current
coefficients). Convergence is declared when the maximum absolute change in
the coefficient vector falls below \code{tol}. Handles the degenerate case
\code{r = 0} (standard OLS on demeaned data) as a special case. Supports
both the strictly-exogenous (\code{"static"}, Bai 2009) and the
predetermined-regressor (\code{"dynamic"}, Moon and Weidner 2017) projection
schemes.
}
\keyword{internal}
