View source: R/estimate_networks_by_group.R
| estimate_networks_by_group | R Documentation |
Estimates network models separately for each group in the data.
estimate_networks_by_group(
data,
group_var,
columns,
default = "ggmModSelect",
stepwise = TRUE,
corMethod = "spearman",
abbreviate_vars = FALSE,
abbr_minlength = 3,
labels = NULL,
set_labels_on_graph = TRUE
)
data |
Data frame containing the data. |
group_var |
Name of the grouping variable column. |
columns |
Character vector of variable names to include. |
default |
Network estimation method (default: "ggmModSelect"). |
stepwise |
Logical; use stepwise model selection. |
corMethod |
Correlation method (default: "spearman"). |
abbreviate_vars |
Logical; abbreviate variable names. |
abbr_minlength |
Minimum length for abbreviated names. |
labels |
Optional custom labels for nodes. |
set_labels_on_graph |
Logical; apply labels to graph object. |
A named list with one estimated network (a bootnetResult object)
per group. Each network carries the attribute var_mapping, a tibble
that maps the original variable names to the labels used.
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))
items$sex <- rep(c("Female", "Male"), each = n / 2)
nets <- estimate_networks_by_group(items, group_var = "sex",
columns = names(items)[1:8],
default = "EBICglasso")
names(nets)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.