• Methods for Network Analysis Book Club
  • Welcome
    • Book club meetings
    • Pace
  • 1 (skip)
  • 2 (skip)
  • 3 (skip)
  • 4 R Basics
    • 4.1 Intro to the book club
      • 4.1.1 What is this book about?
      • 4.1.2 Who is the author?
      • 4.1.3 What makes a “network”?
    • 4.2 Vectors, matrices and data.frames
    • 4.3 Indexing and Subsetting
    • 4.4 Loading Packages
    • 4.5 Meeting Videos
      • 4.5.1 Cohort 1
  • 5 Understanding Network Data Structures
    • 5.1 Edge lists
    • 5.2 Adjacency matrices (recommended structure)
    • 5.3 Meeting Videos
      • 5.3.1 Cohort 1
  • 6 Your First Network
    • 6.1 Creating a project
    • 6.2 Loading data into R
    • 6.3 Manual data entry
    • 6.4 From data to networks
    • 6.5 Meeting Videos
      • 6.5.1 Cohort 1
  • 7 Network Visualization and Aesthetics
    • 7.1 The Basics
      • 7.1.1 Nodes
    • 7.2 Edges
    • 7.3 Layouts
    • 7.4 Adding attributes to a network object
    • 7.5 Plotting based on attributes
      • 7.5.1 Cohort 1
  • 8 Ego Networks
    • 8.1
    • 8.2 Meeting Videos
      • 8.2.1 Cohort 1
  • 9 Calculating Network Size and Density
    • 9.1 Load data
    • 9.2 Number of vertices
    • 9.3 Number of edges
    • 9.4 Density
    • 9.5 Meeting Videos
      • 9.5.1 Cohort 1
  • 10 Affiliation Data
    • 10.1 Indirect connections
      • 10.1.1 Unipartite Projection
    • 10.2 Tripartite network analysis?
      • 10.2.1 Lab
    • 10.3 Meeting Videos
      • 10.3.1 Cohort 1
  • 11 Transitivity, Structural Balance, and Hierarchy
    • 11.1 Load the data
    • 11.2 The Dyad
    • 11.3 The Triad
    • 11.4 Calculating a triad census
    • 11.5 Random graphs galore
    • 11.6 Producing a tau statistic
    • 11.7 Meeting Videos
      • 11.7.1 Cohort 1
  • 12 Centrality
    • 12.1 SLIDE 1
    • 12.2 Meeting Videos
      • 12.2.1 Cohort 1
  • 13 Bridges, Holes, the Small World Problem, and Simulation
    • 13.1 It’s a small world after all
    • 13.2 Measuring connectivity of networks
    • 13.3 One last thing
    • 13.4 Meeting Videos
      • 13.4.1 Cohort 1
  • 14 Finding Groups in Networks
    • 14.1 SLIDE 1
    • 14.2 Meeting Videos
      • 14.2.1 Cohort 1
  • 15 Homophily and Exponential Random Graphs (ERGM)
    • 15.1 SLIDE 1
    • 15.2 Meeting Videos
      • 15.2.1 Cohort 1
  • 16 Positional Analysis in Networks
    • 16.1 SLIDE 1
    • 16.2 Meeting Videos
      • 16.2.1 Cohort 1
  • 17 Culture and Networks
    • 17.1 SLIDE 1
    • 17.2 Meeting Videos
      • 17.2.1 Cohort 1
  • 18 Dynamics
    • 18.1 SLIDE 1
    • 18.2 Meeting Videos
      • 18.2.1 Cohort 1
  • Published with bookdown

Methods for Network Analysis Book Club

5.2 Adjacency matrices (recommended structure)

adjacency <- matrix(c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0), nrow = 5, ncol = 5, dimnames = list(c("Mark", "Peter", "Bob", "Jill", "Aaron"), c("Mark", "Peter", "Bob", "Jill", "Aaron")))

print(adjacency)
##       Mark Peter Bob Jill Aaron
## Mark     0     1   0    1     0
## Peter    1     0   1    0     1
## Bob      0     1   0    1     0
## Jill     1     0   1    0     1
## Aaron    0     1   0    1     0

Pros:

  • More efficient than edge lists (Example: searching connections).

Cons:

  • More suited form computers than human (Example: difficult to record).

Convert edge list to adjacency matrix

edgelist %>% 
  as.matrix() %>% 
  graph_from_edgelist(directed = FALSE) %>%
  as_adjacency_matrix(sparse = TRUE)
## 5 x 5 sparse Matrix of class "dgCMatrix"
##       Mark Peter Jill Bob Aaron
## Mark     .     1    1   .     .
## Peter    1     .    .   1     1
## Jill     1     .    .   1     1
## Bob      .     1    1   .     .
## Aaron    .     1    1   .     .