comparetree {networktree} | R Documentation |
comparetree
Description
Quickly compares two partitions of a networktree object
Usage
comparetree(
tree,
id1 = 2L,
id2 = 3L,
transform = "detect",
highlights = 5,
plot = FALSE,
plot.type = c("compare", "subtract"),
layout = "constrained",
...
)
Arguments
tree |
a networktree object |
id1 |
the first partition |
id2 |
the second partition |
transform |
should stored correlation matrices be transformed to partial correlations or graphical lasso? Can be set to "cor", "pcor", or "glasso". Defaults to automatic detection |
highlights |
the number of comparisons to highlight |
plot |
plot a comparison of the two partitions? |
plot.type |
"compare" or "subtract". "compare" plots the two networks side by side. "subtract" subtracts network 2 from network 1, and plots a network where edge weights indicate the difference |
layout |
layout for the plots. The default "constrained" uses a FR layout from the full dataset |
... |
additional arguments passed to qgraph |
Examples
set.seed(1)
d <- data.frame(trend = 1:200, foo = runif(200, -1, 1))
d <- cbind(d, rbind(
mvtnorm::rmvnorm(100, mean = c(0, 0, 0),
sigma = matrix(c(1, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 1), ncol = 3)),
mvtnorm::rmvnorm(100, mean = c(0, 0, 0),
sigma = matrix(c(1, 0, 0.5, 0, 1, 0.5, 0.5, 0.5, 1), ncol = 3))
))
colnames(d)[3:5] <- paste0("y", 1:3)
## Generate a networktree
tree1 <- networktree(nodevars=d[,3:5], splitvars=d[,1:2])
## Print out the structure
tree1
## Compare any two partitions
comparetree(tree1, id1=2, id2=3, highlights=3)
## Add a comparison plot
comparetree(tree1, id1=2, id2=3, plot=TRUE)
[Package networktree version 1.0.1 Index]