50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

dfms (version 0.2.2)

ICr: Information Criteria to Determine the Number of Factors (r)

Description

Minimizes 3 information criteria proposed by Bai and Ng (2002) to determine the optimal number of factors r* to be used in an approximate factor model. A Screeplot can also be computed to eyeball the number of factors in the spirit of Onatski (2010).

Usage

ICr(X, max.r = min(20, ncol(X) - 1))

# S3 method for ICr print(x, ...)

# S3 method for ICr plot(x, ...)

# S3 method for ICr screeplot(x, type = "pve", show.grid = TRUE, max.r = 30, ...)

Value

A list of 4 elements:

F_pca

T x n matrix of principle component factor estimates.

eigenvalues

the eigenvalues of the covariance matrix of X.

IC

r.max x 3 'table' containing the 3 information criteria of Bai and Ng (2002), computed for all values of r from 1:r.max.

r.star

vector of length 3 containing the number of factors (r) minimizing each information criterion.

Arguments

X

a T x n numeric data matrix or frame of stationary time series.

max.r

integer. The maximum number of factors for which IC should be computed (or eigenvalues to be displayed in the screeplot).

x

an object of type 'ICr'.

...

further arguments to ts.plot or plot.

type

character. Either "ev" (eigenvalues), "pve" (percent variance explained), or "cum.pve" (cumulative PVE). Multiple plots can be requested.

show.grid

logical. TRUE shows gridlines in each plot.

Details

Following Bai and Ng (2002) and De Valk et al. (2019), let NSSR(r) be the normalized sum of squared residuals SSR(r)/(n×T) when r factors are estimated using principal components. Then the information criteria can be written as follows:

ICr1=ln(NSSR(r))+r(n+TnT)+ln(nTn+T) ICr2=ln(NSSR(r))+r(n+TnT)+ln(min(n,T)) ICr3=ln(NSSR(r))+r(ln(min(n,T))min(n,T))

The optimal number of factors r* corresponds to the minimum IC. The three criteria are are asymptotically equivalent, but may give significantly different results for finite samples. The penalty in ICr2 is highest in finite samples.

In the Screeplot a horizontal dashed line is shown signifying an eigenvalue of 1, or a share of variance corresponding to 1 divided by the number of eigenvalues.

References

Bai, J., Ng, S. (2002). Determining the Number of Factors in Approximate Factor Models. Econometrica, 70(1), 191-221. tools:::Rd_expr_doi("10.1111/1468-0262.00273")

Onatski, A. (2010). Determining the number of factors from empirical distribution of eigenvalues. The Review of Economics and Statistics, 92(4), 1004-1016.

De Valk, S., de Mattos, D., & Ferreira, P. (2019). Nowcasting: An R package for predicting economic variables using dynamic factor models. The R Journal, 11(1), 230-244.

Examples

Run this code
library(xts)
library(vars)

ics = ICr(diff(BM14_M))
print(ics)
plot(ics)
screeplot(ics)

# Optimal lag-order with 6 factors chosen
VARselect(ics$F_pca[, 1:6])

Run the code above in your browser using DataLab