knitr::opts_chunk$set( fig.path = "man/figures/index-" ) library("networktree") library("qgraph") library("grid") data("dass", package = "networktree") abbrev <- function(x, n = 7L) { ifelse(nchar(x) > (n + 1L), paste0(substr(x, 1, n), "."), x) }
Correlation-based network models, also known as psychometric networks, provide information about the statistical relationships between observed variables. To reveal significant differences in such networks with respect to covariates, network trees recursively partition the data and fit separate network models in the resulting subsamples.
The networktree package implements two network tree algorithms: model-based trees based on a multivariate normal model and nonparametric trees based on covariance structures.
# depression items from dass 21 nodeVars <- c("dass3_D", "dass42_D", "dass10_D", "dass13_D", "dass31_D", "dass17_D", "dass38_D") dNames <- c("anhedonia", "initiative", "lookforward", "sad", "unenthused", "worthless", "meaningless") dNames <- abbrev(dNames, n = 8L) colnames(dass)[match(nodeVars, colnames(dass))] <- dNames tree_complex <- networktree( nodevars = dass[,dNames], splitvars = dass[,c("age", "race"), drop=FALSE], alpha = 0.01) plot(tree_complex, transform = "pcor", labels = dNames, vsize = 20, label.norm = "OOOOO", tnex = 2.75, partyargs = list(gp = gpar(fontsize=11)), posCol = "#008585", negCol = "#C7522B") ## from hcl.colors(2, "Geyser")
Reference: Jones, P.J., Mair, P., Simon, T., Zeileis, A. (2020). Network trees: A method for recursively partitioning covariance structures. Psychometrika. 85(4), 926-945. doi:10.1007/s11336-020-09731-4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.