rheon.corr.equicorr_loglik¶
- rheon.corr.equicorr_loglik(row: Any, rho: float) float[source]¶
Compute the Gaussian log-density of a standardized row under a common correlation.
Use it to score, offline, a row against an equicorrelation matrix, the
loglikadecomodel writes. To estimate the common correlation from the row, useequicorr_row().Parameters
rowOne row of
nstandardized values.rhoThe common correlation, every off-diagonal entry of the matrix
R. Inside(-1/(n-1), 1)Ris positive definite.
Returns
A float, in closed form with
S1 = sum(x)andS2 = sum(x * x)over the rowx:det R = (1 - rho)**(n-1) * (1 + (n-1) rho) x'R^-1 x = (S2 - rho S1**2 / (1 + (n-1) rho)) / (1 - rho) loglik = -0.5 * (n log(2 pi) + log det R + x'R^-1 x)
It is
nanbelow two entries, and outside(-1/(n-1), 1), whereRis not positive definite.Examples
row = [1.2, 0.8, 1.0, -0.2] independent = rp.corr.equicorr_loglik(row, 0.0) common = rp.corr.equicorr_loglik(row, 0.4) print(round(independent, 3), round(common, 3))
-5.236 -4.716
See also
equicorr_row(), the row’s own estimate of the common correlation.