Estimates a Dynamic Factor Model (DFM) to extract common latent factors from panel data. Uses principal components as initial estimates and optionally refines via EM algorithm.
estimate_dfm(
X,
r = NULL,
p = 1,
ic = c("IC2", "IC1", "IC3"),
max_factors = NULL,
standardize = TRUE,
verbose = FALSE
)A list of class "signaly_dfm" containing:
Matrix of estimated latent factors (T x r)
Matrix of factor loadings (p x r)
VAR coefficient matrices for factor dynamics
Idiosyncratic variance estimates
Number of factors selected
Information criterion values
Fitted values from the model
Residuals (idiosyncratic components)
Matrix or data frame where rows are observations and columns are variables.
Number of factors. If NULL, determined by information criterion.
Number of lags in factor VAR dynamics. Default 1.
Character string specifying information criterion for factor selection: "IC1", "IC2", or "IC3" (Bai & Ng, 2002). Default "IC2".
Maximum number of factors to consider. Default min(10, floor(ncol(X)/2)).
Logical. Standardize variables before estimation. Default TRUE.
Logical for progress messages.
The DFM assumes: $$X_{it} = \lambda_i' F_t + e_{it}$$
where \(F_t\) are common factors, \(\lambda_i\) are loadings, and \(e_{it}\) are idiosyncratic errors. The factors follow VAR dynamics: $$F_t = A_1 F_{t-1} + ... + A_p F_{t-p} + u_t$$
Factor selection uses the Bai & Ng (2002) information criteria which penalize over-fitting while consistently estimating the true number of factors.
Bai, J., & Ng, S. (2002). Determining the number of factors in approximate factor models. Econometrica, 70(1), 191-221.
Stock, J. H., & Watson, M. W. (2002). Forecasting using principal components from a large number of predictors. Journal of the American Statistical Association, 97(460), 1167-1179.
set.seed(123)
n <- 100
p <- 20
X <- matrix(rnorm(n * p), ncol = p)
result <- estimate_dfm(X, r = 2)
print(dim(result$factors))
Run the code above in your browser using DataLab