qis.compute_data_pca_r2

qis.compute_data_pca_r2(data, freq='ME', time_period=None, ewm_lambda=0.94, is_corr=True)[source]

explained-variance shares through time, from an EWM correlation or covariance tensor.

Runs qis.compute_ewm_covar_tensor() on the rows of data as supplied, uncentred (no mean removed), from a zero seed and with the kernel’s default NanBackfill.DEFLATED_FFILL, then applies compute_pca_r2() on each sampling date. A sampling date takes the last row on or before it, so every row of the output is point in time. A missing value counts as a zero observation, which keeps every matrix positive semidefinite, so align a ragged panel first when a gap means a missing price.

Parameters:
  • data (DataFrame) – returns, rows are dates and columns are assets

  • freq (str) – frequency of the sampling dates generated over time_period

  • time_period (TimePeriod) – span of the sampling dates. None uses the span of data

  • ewm_lambda (float) – EWM decay of the tensor

  • is_corr (bool) – decompose the correlation tensor. False decomposes the second-moment tensor, whose components are dominated by the most volatile assets

Returns:

one row per sampling date and one column per component, PC1 to PCn

Return type:

DataFrame