centrality_plots2: Centrality Plot (Version 2)

View source: R/centrality_plots2.R

centrality_plots2R Documentation

Centrality Plot (Version 2)

Description

Creates centrality plots with optional bridge metrics.

Usage

centrality_plots2(
  qgraph_obj,
  network,
  groups = NULL,
  measure0 = "ExpectedInfluence",
  measure1 = NULL,
  color_palette = c("#FF0000", "#00A08A"),
  labels = NULL,
  legend_labels = NULL,
  use_abbrev = TRUE
)

Arguments

qgraph_obj

A qgraph object.

network

Estimated network object.

groups

List of communities for bridge calculation.

measure0

Primary centrality measure name.

measure1

Secondary bridge measure name (NULL for single measure).

color_palette

Character vector of colors.

labels

Named vector mapping node names to custom labels.

legend_labels

Custom legend labels.

use_abbrev

Logical; use abbreviated node names.

Value

A list with table (a data frame with the centrality values of each node) and plot (a ggplot object).

Examples

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")
g <- qgraph::qgraph(net$graph, DoNotPlot = TRUE)
res <- centrality_plots2(g, net,
                         groups = rep(c("A", "B"), each = 4),
                         measure1 = "Bridge Expected Influence (1-step)")
res$table
res$plot

InterconectaR documentation built on Oct. 16, 2026, 1:06 a.m.