Extract Posterior Mean Partial Correlations
Source:R/extractor_functions.R
extract_partial_correlations.RdComputes the posterior mean partial correlation matrix from a model fitted
with bgm(). For GGM models this is the full matrix. For mixed
MRF models this is the matrix for the continuous block. OMRF models
have no partial correlations and return NULL.
Partial correlations are computed from the precision matrix as \(\rho_{ij} = -\Theta_{ij} / \sqrt{\Theta_{ii} \Theta_{jj}}\).
Arguments
- bgms_object
A fitted model object of class
bgms(frombgm()).
Value
A named numeric matrix containing posterior mean partial
correlations, or NULL for OMRF models.
- GGM
A symmetric matrix with ones on the diagonal and one row and column per variable.
- Mixed MRF
A symmetric matrix with ones on the diagonal and one row and column per continuous variable.
- OMRF
NULL(invisibly).
See also
Other extractors:
extract_arguments(),
extract_category_thresholds(),
extract_ess(),
extract_group_params(),
extract_indicator_priors(),
extract_indicators(),
extract_log_odds(),
extract_main_effects(),
extract_pairwise_interactions(),
extract_posterior_inclusion_probabilities(),
extract_precision(),
extract_rhat(),
extract_sbm()
Examples
# \donttest{
fit = bgm(
x = Wenchuan[, 1:3],
variable_type = rep("continuous", 3)
)
#> 2 rows with missing values excluded (n = 360 remaining).
#> To impute missing values instead, use na_action = "impute".
#> Chain 1 (Sampling): ⦗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━⦘ 2000/2000 (100.0%)
#> Chain 2 (Sampling): ⦗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━⦘ 2000/2000 (100.0%)
#> Chain 3 (Sampling): ⦗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━⦘ 2000/2000 (100.0%)
#> Chain 4 (Sampling): ⦗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━⦘ 2000/2000 (100.0%)
#> Total (Sampling): ⦗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━⦘ 8000/8000 (100.0%)
#> Elapsed: 0s | ETA: 0s
extract_partial_correlations(fit)
#> intrusion dreams flash
#> intrusion 1.0000000 0.4937827 0.2986608
#> dreams 0.4937827 1.0000000 0.4222465
#> flash 0.2986608 0.4222465 1.0000000
# }