bkelly-lab/ipca has 270 GitHub stars and 99 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-23 00:02 UTC. Last push 2022-08-15.
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
关于
Instrumented Principal Components Analysis
开发工具README.md
原文Instrumented Principal Components Analysis
This is a Python implementation of the Instrumtented Principal Components Analysis framework by Kelly, Pruitt, Su (2017).
Usage
Exemplary use of the ipca package. The data is the seminal Grunfeld data set as provided on statsmodels. Note, the fit method
takes a panel of data, X, with the following columns:
- entity id (numeric)
- time (numeric)
- and following columns contain characteristics.
as well as a series of dependent variables, y, of the same length as X.
import numpy as np
from statsmodels.datasets import grunfeld
data = grunfeld.load_pandas().data
data.year = data.year.astype(np.int64)
# Establish unique IDs to conform with package
N = len(np.unique(data.firm))
ID = dict(zip(np.unique(data.firm).tolist(),np.arange(1,N+1)))
data.firm = data.firm.apply(lambda x: ID[x])
# use multi-index for panel groups
data = data.set_index(['firm', 'year'])
y = data['invest']
X = data.drop('invest', axis=1)
# Call ipca
from ipca import InstrumentedPCA
regr = InstrumentedPCA(n_factors=1, intercept=False)
regr = regr.fit(X=X, y=y)
Gamma, Factors = regr.get_factors(label_ind=True)
Installing
The latest release can be installed using pip
pip install ipca
The master branch can be installed by cloning the repo and running setup
git clone https://github.com/bkelly-lab/ipca.git
cd ipca
python setup.py install
Documenation
The lastest documenation is published HERE.
Requirements
Running
With the exception of Python 3.6+, which is a hard requirement, the others are the version that are being used in the test environment. It is possible that older versions work.
- Python 3.7+:
- NumPy (1.19+)
- SciPy (1.6+)
- Numba (0.53+)
- progressbar (2.5+)
- joblib (1.0.1+)
Testing
- pandas (1.2.3+)
- scikit-learn (0.24+)
- pytest (4.3+)
- statsmodels (0.11+)
Acknowledgements
The implementation is inspired by the MATLAB code for IPCA made available on Seth Pruitt's website.
References
- Kelly, Pruitt, Su (2017). "Instrumented Principal Components Analysis" SSRN
The package is still in the development phase, hence please share your comments and suggestions with us.
Contributions welcome!
- Matthias Buechner, Leland Bybee
探索相关项目
加载中…