rheon.corr.absorption¶
- rheon.corr.absorption(r: Any, k: int) float[source]¶
Compute Kritzman, Li, Page and Rigobon’s absorption ratio of a correlation matrix.
Use it to measure how much the series move as one: the share of the total variance the top
keigenvectors explain. A high ratio means the market is moving as one thing. To compare a fast and a slow ratio, useabsorption_shift().Parameters
rAn
n x ncorrelation matrix, or a Gram or a closed group’s row, read asrheon.gram.correlation()reads it, without the intercept (the module’s docstring says why).kHow many of the largest eigenvalues to sum, from 1 to
n.
Returns
A float,
sum_{i<=k} lam_i / sum_i lam_iover the eigenvalueslam_iin decreasing order, ornanwhere they sum to 0.Raises
ValueErrorkoutside1..n,ran array that is not square, or a Gram column other than the intercept with no variance.WrongTypeErrorkis not a whole number, such as2.0orTrue. It is both aTypeErrorand aValueError.numpy.linalg.LinAlgErrorris an array holdingnanentries, where numpy’s eigensolver does not converge.
Examples
r = np.array([[1.0, 0.8, 0.7], [0.8, 1.0, 0.75], [0.7, 0.75, 1.0]]) print(round(rp.corr.absorption(r, 1), 3))
0.834
See also
absorption_shift(), a fast ratio against a slow one.spectral(), the eigenpairs themselves.