% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ife.R
\name{.bias_correct}
\alias{.bias_correct}
\title{Compute Bias-Corrected IFE Coefficients (Bai 2009)}
\usage{
.bias_correct(beta, F_hat, Lambda_hat, X_dm_arr, X_tilde, e_mat, N, TT, p, r)
}
\arguments{
\item{beta}{p-vector of uncorrected IFE coefficients}

\item{F_hat}{T x r factor matrix (F'F/T = I_r enforced)}

\item{Lambda_hat}{N x r loading matrix}

\item{X_dm_arr}{T x N x p array of demeaned covariates (after additive FE)}

\item{X_tilde}{T x N x p array of factor-projected demeaned X}

\item{e_mat}{T x N matrix of full-model residuals (from .ife_fit)}

\item{N, TT, p, r}{panel dimensions}
}
\value{
list with elements:
beta_bc  p-vector: bias-corrected coefficients
B_hat    p-vector: estimated cross-section bias term (pre-scaling by 1/N)
C_hat    p-vector: estimated time-heteroskedasticity bias term (pre-scaling by 1/T)
}
\description{
Applies the two-term asymptotic bias correction from Bai (2009)
Theorems 7.1 and 7.2 to the raw IFE coefficient vector:
\deqn{\hat{\beta}^\dagger = \hat{\beta} - \hat{B}/N - \hat{C}/T}
where \eqn{\hat{B}} corrects for cross-sectional heteroskedasticity
(Equation 17) and \eqn{\hat{C}} corrects for time-varying heteroskedasticity
(Equation 19). Both terms require \eqn{T/N^2 \to 0} and \eqn{N/T^2 \to 0}
respectively (Theorem 7.2). For panels of the scale used in the package
examples (\eqn{N \approx 50}, \eqn{T \approx 30}) both conditions hold
approximately.
}
\keyword{internal}
