-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.Rmd
More file actions
61 lines (44 loc) · 2.72 KB
/
README.Rmd
File metadata and controls
61 lines (44 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file and run rmarkdown::render("README.Rmd") -->
```{r, include = FALSE}
knitr::opts_chunk$set(
fig.path = "man/figures/README-"
)
require(networktree)
require(qgraph)
require(grid)
data("dass")
```
Psychometric networks provide information about the statistical relationships between observed variables. ***networktree*** is a package for partitioning psychometric networks to reveal heterogeneity.
Consider a depression network where the nodes represent different symptoms:
```{r, echo = FALSE, fig.height=4, fig.width=4}
# 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")
colnames(dass)[match(nodeVars, colnames(dass))] <- dNames
pcorDassDep <- qgraph(cor(dass[,dNames]), graph="pcor", labels=dNames, vsize=15, layout="spring", label.norm="OOOOO")
```
***networktree*** can be used to identify if this depression network is heterogeneous depending on the sample characteristics. For instance, we can test whether the network differs depending on participants' marital status.
```{r, echo = FALSE}
tree1 <- networktree(nodevars=dass[,dNames], splitvars=dass[,"married",drop=F])
plot(tree1, transform="pcor",
labels=dNames, vsize=15, layout=pcorDassDep$layout, label.norm="OOOOO",
partyargs=list(gp=gpar(fontsize=10)))
```
We can explore multiple characteristics at once, with the more important splitting characteristics being prioritized in the tree model. Continuous partitioning variables (e.g., age) can be included, and ***networktree*** will automatically search for the ideal split point(s).
```{r, echo = FALSE, fig.width=10, fig.height=6.5}
tree_complex <- networktree(nodevars=dass[,dNames], splitvars=dass[,c("age", "race"),drop=F])
plot(tree_complex,transform="pcor",
labels=dNames, vsize=15, layout=pcorDassDep$layout, label.norm="OOOOO",
partyargs=list(gp=gpar(fontsize=7)))
```
Resources:
* [Home Page](https://paytonjjones.github.io/networktree/)
* [Getting Started - Tutorial](https://paytonjjones.github.io/networktree/index.html)
* [CRAN documentation](https://cran.r-project.org/web/packages/networktree/index.html)
* [Example application](https://paytonjjones.github.io/networktree/articles/returns.html)
* [Published paper](https://rdcu.be/b9Kyw) for a more advanced look.
To cite ***networktree***, use:
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](https://doi.org/10.1007/s11336-020-09731-4)