polars_online.corr.equicorr¶
- polars_online.corr.equicorr(r: Any) float[source]¶
Compute the mean off-diagonal correlation of a matrix.
Use it to summarize a correlation matrix by one common correlation, the number a
decomodel tracks. For the same number from one standardized row, useequicorr_row(). For a common correlation per block, useblock_means().Parameters
rA
k x kcorrelation matrix, or a Gram or a closed group’s row, read aspolars_online.gram.correlation()reads it, without the intercept (the module’s docstring says why).nanentries of an array are left out of the mean.
Returns
A float: the mean of the off-diagonal entries. It is
nanbelow two columns, and where every off-diagonal entry isnan, with numpy’sRuntimeWarning.Raises
ValueErrorris an array that is not square, or a Gram column other than the intercept has no variance.
Examples
r = np.array([[1.0, 0.4, 0.2], [0.4, 1.0, 0.3], [0.2, 0.3, 1.0]]) print(round(po.corr.equicorr(r), 3))
0.3
See also
equicorr_row()andequicorr_loglik(), the same model on one row.block_means(), a mean correlation per block.