pca_high_freq()
Run high-frequency PCA on a data matrix.
Usage
pca_high_freq(
X,
k=None,
u=None,
evectors_start=None,
quiet=False,
)This function implements the algorithm proposed by Aït-Sahalia and Xiu (2019), returning the time series of principal components, eigenvalues, and eigenvectors.
A summary of the algorithm’s hypothesis and parametrization can be found in this package’s documentation.
Parameters
X: NDArray[np.number]-
Input data array with shape
(T, d), whereTis the number of observations anddis the number of variables. Must not containnpnanornp.infvalues. k: int | None = None-
Block size used for the high-frequency PCA routine. If
None, it is chosen by a rule-of-thumb. Must be smaller thand u: NDArray[np.number] | None = None-
Jump truncation cutoffs for each variable, with shape
(d,). IfNone, it is chosen by a rule-of-thumb. Must not containnpnan,np.inf, or nonpositive values. evectors_start: NDArray[np.number] | None = None-
Optional initial eigenvector matrix with shape
(d, d)used to warm-start the iteration. If not supplied, the first block of the results will benp.nan. quiet: bool = False-
If
True, suppress progress prints during computation.
Returns
PCAHighFreqResult-
A [
PCAHighFreqResult][hfpca.types.PCAHighFreqResult] object containingthe the PCs (
.pcs), eigenvalue estimates (.evalues), eigenvectorestimates (
.evectors), which can be unpacked into variables. Also contains: PCAHighFreqResult-
the values of
k(.k),u(.u), andd(.d); and PCAHighFreqResult-
methods for extracting PCs, eigenvalues, and eigenvectors as polars
dataframes (
.pcs_as_polars()). See the class documentation for moredetails.
Raises
TypeError-
If
X,u, orevectors_startare not numpy arrays; if they do not have a numeric dtype; or ifkis not an integer. ValueError-
If
Xis not 2D, or ifuorevectors_startdo not have the correct dimensions; if any of the inputs contain NaN or Inf values; ifucontains nonpositive values; or ifkis smaller thandor larger thanT.