## ----setup, include = FALSE--------------------------------------------------- has_cograph <- requireNamespace("cograph", quietly = TRUE) knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 6, dpi = 100) library(psychnets) ## ----check, echo = FALSE, results = "asis", eval = !has_cograph--------------- # cat("> `cograph` is not installed, so the cograph plotting chunks below are skipped.") ## ----fit, eval = has_cograph-------------------------------------------------- fit <- ebic_glasso(SRL_GPT) fit ## ----default, eval = has_cograph---------------------------------------------- plot(fit) ## ----splot-default, eval = has_cograph---------------------------------------- cograph::splot(fit) ## ----layouts, eval = has_cograph, fig.width = 9, fig.height = 4.5------------- op <- par(mfrow = c(1, 2), mar = c(1, 1, 3, 1)) cograph::splot(fit, layout = "circle", title = "circle") cograph::splot(fit, layout = "spring", seed = 11, title = "spring") par(op) ## ----nodes, eval = has_cograph------------------------------------------------ cograph::splot( fit, layout = "circle", scale_nodes_by = "strength", node_size_range = c(4, 12), node_fill = c("#4C78A8", "#F58518", "#54A24B", "#B279A2", "#E45756"), node_border_color = "white", node_border_width = 2, label_size = 0.9, title = "Node size scaled by strength" ) ## ----edges, eval = has_cograph------------------------------------------------ cograph::splot( fit, layout = "circle", threshold = 0.05, edge_width_range = c(0.5, 5), edge_positive_color = "#2A9D8F", edge_negative_color = "#E76F51", edge_labels = TRUE, edge_label_size = 0.7, edge_label_bg = "white", title = "Thresholded edge weights" ) ## ----edge-weights, eval = has_cograph, fig.width = 7, fig.height = 4.5-------- cograph::plot_edge_weights(fit) ## ----bootstrap, eval = has_cograph, fig.width = 8, fig.height = 5------------- set.seed(1) bs <- net_boot(SRL_GPT, method = "glasso", n_boot = 250, cores = 1) plot(bs) ## ----edge-diff-box, eval = has_cograph, fig.width = 6.5, fig.height = 6.5----- plot(bs, type = "edge_diff") ## ----edge-diff-forest, eval = has_cograph, fig.width = 7, fig.height = 5------ plot(difference_test(bs, type = "edge"), style = "forest") ## ----themes, eval = has_cograph, fig.width = 9, fig.height = 4.5-------------- op <- par(mfrow = c(1, 2), mar = c(1, 1, 3, 1)) cograph::splot(fit, theme = "minimal", title = "minimal") cograph::splot(fit, theme = "colorblind", title = "colorblind") par(op) ## ----group-data, include = FALSE---------------------------------------------- grouped_srl <- rbind( data.frame(SRL_GPT, source = "GPT", check.names = FALSE), data.frame(SRL_Claude, source = "Claude", check.names = FALSE) ) ## ----groups, eval = has_cograph, fig.width = 8, fig.height = 4.5-------------- group_fit <- psychnet(grouped_srl, group = "source", method = "glasso") cograph::splot(group_fit, layout = "circle", psych_styling = TRUE) ## ----export, eval = FALSE----------------------------------------------------- # cograph::splot(fit, layout = "circle", filename = "network.png", # width = 8, height = 8, res = 300)