By Ayla Pollmann (2022)
While there is lots of information out there, this is a relatively new method and the material often assumes an already quite thorough understanding. Here, you will find an easy to follow example of how to get started with network analysis, making it look pretty and helpful resources that guided me throughout my project.
In this introduction, we will use two data sets to
References are linked throughout the text.
Introduction
Network models are statistical structures designed to extract networks from data.
What does a network consist of?
-
Variables are represented as nodes
-
Relationships between variables are presented as edges (lines)
-
Edges are partial correlation coefficients. More information can be found here.
Getting started
- If you have a basic understanding of network analysis, this is a useful introduction by the Amsterdam Summer School 2020.
- The most used R packages for network analysis are currently qgraph or igraph. Guidelines on which estimation methods to use can be found here.
- Bootnet. Bootnet allows to estimate and bootstrap networks based on the Gaussian graphical model and visualized in qgraph. For a tutorial paper, please refer to Epskamp et al. (2018).
Install required packages
knitr::opts_chunk$set(echo = TRUE)
#Method 1
#install packages("qgraph")
#Method 2
#install.packages("bootnet")
#install.packages("ggplot2")
#install.packages("misty")
#install.packages("devtools")
#install_github('hfgolino/EGA', force = TRUE)
#install.packages("MASS")
#install.packages("rockchalk")
#loading packages
library(qgraph)
library(bootnet)
library(ggplot2)
library(misty)
library(devtools)
library(EGAnet)
library(MASS)
library(rockchalk)
Method 1: Social Network
To get started please download the Game of Thrones data set here. Store it in the same folder as your RmD file.
Read in Data
GoT_Data <- read.csv("stormofswords.csv")
qgraph(GoT_Data)
Define Groups
Now, you can do lots of fun things with the network. For example, you could illustrate different groups. In this case different “houses” or families inside GoT.
#By changing the number behind the houses you can change the group membership
Groups <- c(rep("House Targaryen",15),rep("House Stark",10))
qgraph(GoT_Data, groups = Groups)
Change Layout
#Change layout
qgraph(GoT_Data, groups = Groups, layout = "circle")
#or try "groups". Remove "#" to run the next line.
#qgraph(GoT_Data, groups = Groups, layout = "groups")
Method 2: Random Network
Create Matrix
R <- lazyCor(X = 0.75, d = 13)
SD <- c(0.3, 0.5, -0.8, 0.2, 0.5, 0.6, 1.5, 1.2, 0.3, 1.2, 0.5, -0.2, 1.1)
Matrix <- lazyCov(Rho = R, Sd = SD)
Estimate Network using Bootnet
Bootnet allows to estimate and bootstrap networks based on the Gaussian graphical model, visualized in qgraph. Please refer to Epskamp et al. (2018).
Matrix_Network <- estimateNetwork(Matrix, default = "EBICglasso")
plot(Matrix_Network)
Change Theme
#change themes, for example: theme = "Fried" or "Hollywood"
plot(Matrix_Network, theme = "Reddit")
Pretty Network Analysis Layout
Here, we are using the colorblind-friendly colormap “viridis”.
As seen in I WILL LINK MY OWN PAPER HERE SOMEDAY
plot(Matrix_Network, posCol = "gray25", negCol = "grey", negDashed = TRUE, fade = FALSE,
esize = 4, color = c("#440154FF", "#21908CFF","#3B528BFF", "#5DC863FF", "#9FDA3AFF"),
border.color = "white", border.width = 2, label.color = "white",
vsize = 8.5, curve = 0.6, curveAll = T)
Centrality
Centrality of node
-
The centrality of a node is the relative importance of a node
-
This is measured through strength, betweenness, closeness, and expected influence
For example: Node strength
- To determine node strength, the number of direct connections to other nodes as well as the absolute strength-values of connections is taken into account
centralityPlot(Matrix_Network, include = c("Strength", "Closeness","Betweenness","ExpectedInfluence"))
Clustering
Clusterring highlights how nodes are interconnected among themselves in contrast to other clusters in the network.
Please refer to this tutorial by E. Fried on clustering methods in network analysis and this paper by Golino & Epskamp (2017) specifically on the EGA algorithm.
EGAmatrix <-EGA(Matrix, plot.EGA = TRUE, plot.type = c("qgraph"), n=10)
Additional analysis
Bridge nodes.
We calculate bridge nodes/centrality using bridge strength. Bridge strength refers to the sum of the absolute value of all edges between a node of a cluster to all the nodes of the opposing cluster. Please refer to networktools, Jones et al. (2019) and Vanzulah (2017).
Network Comparison Test.
Network Comparison Test (NCT) is a permutation test. The NCT estimates the network structure and calculates a metric that functions as the observed test statistic. Group membership is multiple times rearranged via permutation, followed by a recalculation of the network structure and test statistic. This is resulting in a reference distribution. The NCT then compares the first observed test statistic with this reference distribution, indicating whether the observed test statistic is significantly different. For network comparisons, please refer to Borkulo et al. (2017).
Thank you for reading my introduction to & recommendations for materials on network analysis! If you have any questions, please don’t hesitate to get in contact.