Estimates networks for different groups within a data frame, using `estimate_single_network` internally. Produces separate network visualizations and metrics for each group.
Arguments
- df
A data frame containing the variables and group variable.
- Vars
Character vector of variable names to include in the network. If NULL (default), all columns except GroupVar are used.
- GroupVar
Character string specifying the grouping variable name.
- layout
Layout algorithm for network plots. Defaults to "circle".
- color
Node color(s). Defaults to "#EEEEEE".
- default
Network estimation method. Defaults to "EBICglasso".
- var_types
Variable types for MGM. If NULL, auto-detected.
- qgraph_args
Additional arguments for qgraph.
- network_args
Additional arguments for bootnet::estimateNetwork.
- verbose
Print progress messages. Defaults to TRUE.
- min_group_size
Minimum group size required. Groups with fewer observations are skipped. Defaults to 30.
Value
A list of class "grouped_network_analysis" containing:
networks: List of network objects per groupnetwork_matrices: List of adjacency matrices per grouppredictions: List of prediction results per groupcentralities: List of centrality measures per groupqgraphs: List of qgraph plot objects per groupgroup_sizes: Sample sizes per groupfailed_groups: Groups that failed estimation
Examples
if (FALSE) { # \dontrun{
# Estimate networks by group
results <- estimate_grouped_networks(
df = my_data,
Vars = c("var1", "var2", "var3", "var4"),
GroupVar = "group"
)
# Access results for specific group
results$networks$GroupA
results$predictions$GroupA
# Compare networks
compare_networks(results, groups = c("GroupA", "GroupB"))
} # }