Skip to content

Python code to compute optimal number of factors for large datasets

Notifications You must be signed in to change notification settings

larsspreng/Factor-Selection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Factor-Selection

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)

Example

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()

About

Python code to compute optimal number of factors for large datasets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages