% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ife.R
\name{ife}
\alias{ife}
\title{Estimate Interactive Fixed Effects Model (Bai 2009)}
\usage{
ife(
  formula,
  data,
  index,
  r = 1L,
  force = "two-way",
  se = "standard",
  bias_corr = FALSE,
  method = "static",
  M1 = 1L,
  tol = 1e-09,
  max_iter = 10000L
)
}
\arguments{
\item{formula}{R formula: \code{outcome ~ covariate1 + covariate2 + ...}}

\item{data}{data.frame in long format (one row per unit-time observation)}

\item{index}{character(2): \code{c("unit_id_column", "time_id_column")}}

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

\item{force}{additive FE specification: \code{"none"} | \code{"unit"} | \code{"time"} |
\code{"two-way"} (default \code{"two-way"})}

\item{se}{SE type: \code{"standard"} | \code{"robust"} | \code{"cluster"}
(default \code{"standard"}; \code{"cluster"} clusters by unit id)}

\item{bias_corr}{logical; if \code{TRUE} apply bias correction. For
\code{method = "static"} uses the two-term Bai (2009) Sec. 7 correction
(B/N + C/T). For \code{method = "dynamic"} uses the three-term Moon and
Weidner (2017) correction (B1/T + B2/N + B3/T). Requires r > 0 and
at least one covariate. (default \code{FALSE})}

\item{method}{\code{"static"} (default) for Bai (2009) strictly-exogenous
regressors; \code{"dynamic"} for Moon and Weidner (2017) predetermined
regressors (e.g. lagged dependent variable). The dynamic estimator uses
double projection M_Lambda M_F on X in the SVD loop.}

\item{M1}{integer; lag bandwidth for the B1 dynamic bias term
(default \code{1L}). Only used when \code{method = "dynamic"} and
\code{bias_corr = TRUE}.}

\item{tol}{convergence tolerance (default \code{1e-9})}

\item{max_iter}{maximum iterations (default \code{10000L})}
}
\value{
An S3 object of class \code{"ife"} with the following components:
\itemize{
\item \code{coef} -- named p-vector of estimated coefficients
\item \code{vcov} -- p x p variance-covariance matrix
\item \code{se} -- named p-vector of standard errors
\item \code{tstat} -- named p-vector of t-statistics
\item \code{pval} -- named p-vector of two-sided p-values
\item \code{ci} -- p x 2 matrix of 95\% confidence intervals (CI.lower, CI.upper)
\item \code{table} -- data.frame coefficient table (Estimate, Std.Error, t.value, Pr.t, CI.lower, CI.upper)
\item \code{F_hat} -- T x r estimated factor matrix
\item \code{Lambda_hat} -- N x r estimated loading matrix
\item \code{residuals} -- T x N residual matrix (full model)
\item \code{sigma2} -- estimated error variance
\item \code{df} -- residual degrees of freedom
\item \code{n_iter} -- iterations to convergence
\item \code{converged} -- logical
\item \code{N}, \code{T}, \code{r}, \code{force}, \code{se_type} -- model dimensions and options
\item \code{call} -- matched call
}
}
\description{
Fits the panel model
\deqn{y_{it} = \alpha_i + \xi_t + X_{it}'\beta + \lambda_i'F_t + u_{it}}
for balanced panel data with analytical standard errors.
}
\examples{
data(cigar, package = "xtife")
fit <- ife(sales ~ price, data = cigar, index = c("state", "year"),
           r = 2, force = "two-way", se = "standard")
print(fit)
}
\references{
Bai, J. (2009). Panel data models with interactive fixed effects.
\emph{Econometrica}, 77(4), 1229--1279. \doi{10.3982/ECTA6135}

Moon, H.R. and Weidner, M. (2017). Dynamic linear panel regression models
with interactive fixed effects. \emph{Econometric Theory}, 33, 158--195.
\doi{10.1017/S0266466615000328}

Bai, J. and Ng, S. (2002). Determining the number of factors in approximate
factor models. \emph{Econometrica}, 70(1), 191--221. \doi{10.1111/1468-0262.00273}
}
