Like posterior_Sigma but converts each posterior covariance
draw to a correlation matrix before summarising, giving
\(\rho^{mm^\prime}_{jj^\prime} = \Sigma^{mm^\prime}_{jj^\prime} /
\sqrt{\Sigma^{mm}_{jj}\Sigma^{m^\prime m^\prime}_{j^\prime j^\prime}}\).
This is the quantity displayed in the heatmaps of the paper.
Usage
posterior_cor(fit, domains = NULL, summary = c("median", "mean", "none"))Arguments
- fit
A fitted
"spbgfm"object fromspbgfm.- domains
Optional length-2 integer vector
c(m1, m2)selecting a block of the matrix: the within-domain block \(\Sigma^{mm}\) whenm1 == m2, the cross-domain block \(\Sigma^{mm^\prime}\) otherwise.NULL(default) returns the full \(J \times J\) matrix.- summary
One of
"median"(default),"mean"or"none". With"none"the full array of posterior draws is returned.
Examples
# \donttest{
sim <- simulate_spbgfm(n = 20, J = c(30, 10), seed = 1)
fit <- spbgfm(sim$Y, K = 5, niter = 2000, verbose = FALSE)
cross <- posterior_cor(fit, domains = c(1, 2)) # bacteria vs viruses
dim(cross)
#> [1] 30 10
# }