View source: R/calculate_centrality_sd_correlation.R
| calculate_centrality_sd_correlation | R Documentation |
Calculates correlation between centrality indices and standard deviations.
calculate_centrality_sd_correlation(Data, Centralitys)
Data |
Data frame with the original data (one column per node). |
Centralitys |
A list with a |
A correlation object (from the correlation package) with the
correlation of each of the two centrality indices with the standard
deviation of the nodes.
set.seed(123)
n <- 300
f1 <- rnorm(n)
f2 <- 0.3 * f1 + rnorm(n)
items <- data.frame(
sapply(1:4, function(i) 0.7 * f1 + rnorm(n, 0, 0.7)),
sapply(1:4, function(i) 0.7 * f2 + rnorm(n, 0, 0.7))
)
names(items) <- c(paste0("A", 1:4), paste0("B", 1:4))
net <- bootnet::estimateNetwork(items, default = "EBICglasso")
ct <- qgraph::centralityTable(net)
ct <- ct[ct$measure %in% c("Strength", "ExpectedInfluence"),
c("graph", "node", "measure", "value")]
tab <- tidyr::pivot_wider(ct, names_from = "measure", values_from = "value")
calculate_centrality_sd_correlation(items, list(table = tab))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.