Skip to content

sydx/xpca

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xpca

Implementations of extended PCA methods, such as IPCA and EWMPCA.

Installation

pip install xpca

Paper

See Iterated and exponentially weighted moving principal component analysis on SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3913940

Usage

import xpca

Iterated PCA (IPCA)

# df is a pandas DataFrame
first_year = 2008; last_year = 2020
Z_periods_ipca = []
model = xpca.IPCA()
for period in [str(x) for x in range(first_year, last_year+1)]:
    df_period = df.loc[period]
    model.fit(df_period)
    Z_period = model.transform(df_period)
    Z_periods_ipca.append(Z_period)
Z_periods_ipca = np.vstack(Z_periods_ipca)

Exponentially weighted moving PCA (EWMPCA)

xs = df.values
ewmpca = xpca.EWMPCA(alpha=.9305)
zs_ewmpca = ewmpca.add_all(xs)

About

Implementations of extended PCA methods, such as IPCA and EWMPCA

Resources

License

Stars

Watchers

Forks

Packages

No packages published