Data Source: I’m using the same data that was used for the Unit 1 case study.
Research Question: How do teacher ans student perspectives on classroom friendships relate to student achievement? Or how does achievement relate to the centrality of students to the social network according to students versus teachers?
I think that achievement is an interesting thing to look at for social networks in schools because it impacts how students behave in the classroom setting. Therefore, it is likely that the teacher will have a different perspective on friendship ties within the classroom than the students will because students have a deeper knowledge of their social ties both within and outside of the classroom.
install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("tidygraph")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("ggraph")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 1.0.1
## ✔ tibble 3.1.8 ✔ dplyr 1.1.0
## ✔ tidyr 1.3.0 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(tidygraph)
##
## Attaching package: 'tidygraph'
##
## The following object is masked from 'package:stats':
##
## filter
library(ggraph)
library(readxl)
student_friends <- read_excel("data/student-reported-friends.xlsx",
col_names = FALSE)
## New names:
## • `` -> `...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`
rownames(student_friends) <- 1:27
## Warning: Setting row names on a tibble is deprecated.
colnames(student_friends) <- 1:27
teacher_friends <- read_excel("data/teacher-reported-friends.xlsx",
col_names = FALSE)
## New names:
## • `` -> `...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`
rownames(teacher_friends) <- 1:27
## Warning: Setting row names on a tibble is deprecated.
colnames(teacher_friends) <- 1:27
student_attributes <- read_excel("data/student-attributes.xlsx")
student_edges <- read_csv("data/student-edges.csv")
## Rows: 203 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (3): from, to, weight
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
teacher_matrix <- as.matrix(teacher_friends)
teacher_network <- as_tbl_graph(teacher_matrix, directed = TRUE)
## Warning in (is.null(rownames(x)) && is.null(colnames(x))) || colnames(x) == :
## 'length(x) = 27 > 1' in coercion to 'logical(1)'
teacher_edges <- teacher_network %>%
activate(edges) %>%
as_tibble()
student_network <- tbl_graph(edges = student_edges,
nodes = student_attributes,
directed = TRUE)
teacher_network <- tbl_graph(edges = teacher_edges,
nodes = student_attributes,
directed = TRUE)
ggraph(student_network, layout = "stress") +
geom_edge_arc(arrow = arrow(length = unit(1, 'mm')),
end_cap = circle(3, 'mm'),
start_cap = circle(3, 'mm'),
alpha = .2) +
geom_node_point(aes(size = local_size(),
color = achievement)) +
geom_node_text(aes(label = id),
repel=TRUE) +
labs(title = "Student Social Network by Achievement According to Students")
## Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.
ggraph(teacher_network, layout = "stress") +
geom_edge_arc(arrow = arrow(length = unit(1, 'mm')),
end_cap = circle(3, 'mm'),
start_cap = circle(3, 'mm'),
alpha = .2) +
geom_node_point(aes(size = local_size(),
color = achievement)) +
geom_node_text(aes(label = id),
repel=TRUE) +
labs(title = "Student Social Network by Achievement According to Teacher")
In the two sociograms, it’s clear that the students’ and teacher’s perspectives differ on who is central to the social network. The students tended to place students with high achievement scores as more central to the network than the teacher did. Additionally, the teacher placed the students in more isolated clusters than the students did, with the students with high achievement scores being on the outskirts of each cluster.
These findings may reflect that students with higher achievement scores engage in less social behaviors in classroom settings. Additionally, it may suggest that students with more social ties perform better in school. However, either of these hypotheses would require more research and observation to validate.