A brief tutorial on the networktree package


Psychological network analysis is a valuable tool for understanding the relationships among components of mental disorders, personality traits, or other psychological variables.

But what if those networks are different for different types of people? After all, can we really expect that relationships between psychological variables will hold constant for all age groups, genders, nationalities, ideologies, political orientations, etc.?

That’s where networktree comes in. The networktree package allows for “model-based recursive partitioning” of psychometric networks– a phrase better explained with a picture than with words:


Essentially, networktree allows you to split your network into several subgroups depending on moderating variables (also called “split” variables). These split variables can be categorical, ordinal, or continuous.

So how can you get started with networktree? The first step is to download the package from CRAN:


Then, we’ll need some relevant data. The bigger the sample, the better. To find subtle splits with strict significance levels, you’ll want at least a few hundred observations.

We can try out some examples with the workaholic dataset that is included in the package. It includes items from the Obsessive-Compulsive Inventory – Revised (OCIR) which we can use to form a network.

OCD_vars <- paste("OCIR", 1:18, sep="")
OCD_names <- c("hoard1","check1","arrange1","count","contaminate",
"hoard3", "check3", "arrange3", "numbers2",
"wash2", "thought3")
cor_OCD <- cor(workaholic[,OCD_vars])
q1 <- qgraph(cor_OCD, layout="spring", labels=OCD_names)


Now we can try out the networktree() function. For now, let’s just look to see if there is a split by gender. All we have to do is enter the network-related variables in the nodevars argument, and the split variables in the splitvars argument.

cor_gender <- networktree(nodevars=workaholic[,OCD_vars], splitvars=workaholic[,"Gender"])


If you want to include more split variables, you can include as many as you want. The algorithm prioritizes the “biggest” splits first and always considers significance level, so you don’t need to worry too much about overfitting. We used a correlation network before, but we can also use other types of estimation, such as GLASSO.

glasso <- networktree(nodevars=workaholic[,OCD_vars], splitvars=workaholic[,c("Gender", "Workaholism_diagnosis")],transform="glasso")
plot(glasso, layout="spring")


That’s just a taste of what networktree can do. Because it shares a foundation with the partykit package, networktree is capable of a whole host of options with regards to how you are splitting things up.

This tutorial is just a basic intro which I plan to update along with additional vignettes at a later date. So stay tuned for more, and in the meantime, download the package and start playing around with your data!

Source link


Please enter your comment!
Please enter your name here