Kullback-Leibler divergence of an estimated Gaussian graphical model
Source:R/loss.R
kl_divergence.RdComputes the Kullback-Leibler divergence from the true zero-mean Gaussian \(N(0, \Sigma)\) to the estimated one \(N(0, \hat\Theta^{-1})\), $$KL = \frac{1}{2}\left[\mathrm{tr}(\Sigma\hat\Theta) - \log|\Sigma\hat\Theta| - p\right].$$ Twice this quantity is Stein's (entropy) loss of \(\hat\Theta\).
Value
A non-negative number, or NA if \(\Sigma\hat\Theta\)
has a zero or negative determinant (e.g. theta_hat is not positive
definite), the inputs have missing values, or the computation fails.