Learn R Programming

SignalY (version 1.1.1)

estimate_dfm: Dynamic Factor Model Estimation

Description

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.

Usage

estimate_dfm(
  X,
  r = NULL,
  p = 1,
  ic = c("IC2", "IC1", "IC3"),
  max_factors = NULL,
  standardize = TRUE,
  verbose = FALSE
)

Value

A list of class "signaly_dfm" containing:

factors

Matrix of estimated latent factors (T x r)

loadings

Matrix of factor loadings (p x r)

var_coefficients

VAR coefficient matrices for factor dynamics

idiosyncratic_var

Idiosyncratic variance estimates

r_selected

Number of factors selected

ic_values

Information criterion values

fitted_values

Fitted values from the model

residuals

Residuals (idiosyncratic components)

Arguments

X

Matrix or data frame where rows are observations and columns are variables.

r

Number of factors. If NULL, determined by information criterion.

p

Number of lags in factor VAR dynamics. Default 1.

ic

Character string specifying information criterion for factor selection: "IC1", "IC2", or "IC3" (Bai & Ng, 2002). Default "IC2".

max_factors

Maximum number of factors to consider. Default min(10, floor(ncol(X)/2)).

standardize

Logical. Standardize variables before estimation. Default TRUE.

verbose

Logical for progress messages.

Details

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.

References

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.

Examples

Run this code
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