This repository contains a Python class that can be used to automatically compute criteria to determine the optimal number of factors for high-dimensional factor models.
Thus far, the class includes criteria from the following papers:
- Ahn, S.C. and Horenstein, A.R. (2013), Eigenvalue Ratio Test for the Number of Factors. Econometrica, 81: 1203-1227. https://doi.org/10.3982/ECTA8968
- Growth Ratio Criterion (function: AH_crit_GR)
- Eigenvalue Ratio Criterion (function: AH_crit_ER)
Import the class and NumPy
from fsmodule import FactorSelection
import numpy as np
Simulate example data
X = np.random.rand(100,200)
Create a factor selection object and conduct all available tests using the selection function
fs = FactorSelection(X,6)
fs.selection()
Individual tests can be conducted by calling, for example,
r0 = fs.AH_crit_ER()