View source: R/r2_distribution.R
r2_distribution | R Documentation |
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
r2_distribution(SEmatrix, cormat, names = NULL, indices = NULL)
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 |
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.
ryan2019SEset \insertRefhaslbeck2018wellSEset
network_to_SEset, find_parents
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.