r2_distribution: Compute Controllability Distribution in the SE-set

View source: R/r2_distribution.R

r2_distributionR Documentation

Compute Controllability Distribution in the SE-set

Description

A function used to analyse the SEset results. For each member of the SE-set, calculate the proportion of explained variance in each child node, when predicted by all of its parent nodes

Usage

r2_distribution(SEmatrix, cormat, names = NULL, indices = NULL)

Arguments

SEmatrix

An n \times p matrix containing the SEset, where each row represents a p \times p weights matrix stacked column-wise

cormat

A p \times p matrix containing the marginal covariances or correlations

names

optional character vector containing dimension names

indices

option vector of matrix indices, indicating which variables to compute the R^2 distribution for

Value

Returns an n \times p matrix of R^2 values. For each member of the SE-set, this represents the variance explained in node X_i by it's parents in that weighted DAG.

References

\insertRef

ryan2019SEset \insertRefhaslbeck2018wellSEset

See Also

network_to_SEset, find_parents

Examples

# first estimate the precision matrix
data(riskcor)
omega <- (qgraph::EBICglasso(riskcor, n = 69, returnAllResults = TRUE))$optwi
# qgraph method estimates a non-symmetric omega matrix, but uses forceSymmetric to create
# a symmetric matrix (see qgraph:::EBICglassoCore line 65)
omega <- as.matrix(Matrix::forceSymmetric(omega)) # returns the precision matrix

SEmatrix <- network_to_SEset(omega, digits=3)

r2set  <- r2_distribution(SEmatrix, cormat = riskcor, names = NULL, indices = c(1,3,4,5,6))
# Plot results
apply(r2set,2,hist)
# For ggplot format, execute
# r2set <- tidyr::gather(r2set)

SEset documentation built on March 18, 2022, 5:51 p.m.