Row

Student Reported Friendships

Row

Teacher Reported Friendships

---
title: "What influence do students with high achievement levels have in their student network?"
output: 
  flexdashboard::flex_dashboard:
    theme:
      bg: "#FFFFFF"
      fg: "#000000" 
      primary: "#8E7DBE"
      base_font:
        google: Prompt
      code_font:
        google: JetBrains Mono
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
```

```{r}
install.packages("tidyverse")
install.packages("tidygraph")
install.packages("ggraph")
install.packages("readxl")
library(tidyverse)
library(tidygraph)
library(ggraph)
library(readxl)
```

##  {.sidebar}

This analysis is centered around data gathered from the work of Matthew Pittinsky and Brian V. Carolan (2008), who used social network analysis to compare perceptions of student friendships through the lens of both students and teachers. To answer the research question, the existing data on 27 students' reported friendships, their individual attributes and teacher reported friendships were used.

Based on student attribute data, Students 1, 4, 7, 9, 11, 24, 25, and 27 are the class's highest achievers. Interestingly,it appears as though nearly all of the highest achievers in the class also happen to have largest amount of friendship ties, with each having among the biggest nodes in the network.

Based on the teacher reported friendships, there is a difference, with the teacher reporting their perception that the average and even lower performing students have the most friendship ties, though there are some high achievers in the mix.

The sociograms to the right show the friendship ties based on the student reported data and the teacher reported data, respectively. In these graphs, larger nodes signify a larger amount of friendship ties, while the arrows signify relationships the relationships between each student. A one-sided arrow to or from a student represents a reported friendship, while a two sided arrow represents a reciprocated friendship. Each graph has a key that represents whether a student is average, high or low achieving. Additionally, the "local_size ()" represents the size of each students' number of friendship ties, ranging from 5 to 20+.

It is possible that these results may be coincidence and there are other attributes that have not been considered that the higher achieving students might possess that would draw other students to identify or perceive them as friends. Friendships, especially among middle schoolers who are going through many mental and emotional changes, tend to be very dynamic and sometimes even short-lived. Often times, the formation of these relationships and the changes that occur within them can be nonsensical or overlooked by adults. This could be a possible explanation for the differences in perception among teachers and students.

However, based solely on this data, and seeing the amount of influence/ties that the higher achieving students have within their class network, one question in particular that could be explored further in the future is:

-   How, if at all, can these relationships be leveraged positively to boost achievement among their average or lower performing students?

Leveraging these ties could possibly have a positive outcome on overall student achievement. Research has shown that positive academic interaction within student networks can lead to higher achievement levels on assessments. [A 2020 article by Shelly J. Schmidt](https://ift.onlinelibrary.wiley.com/doi/full/10.1111/1541-4329.12176), showed that not only was this possible, but students were "16 times more likely to become study partners with a friend than a non friend" emphasizing the importance of friendships in academic success.

## Row

### Student Reported Friendships {.tabset data-width="650"}

```{r}

student_friends <- read_excel("data/student-reported-friends.xlsx", col_names = FALSE)

rownames(student_friends) <- 1:27

colnames(student_friends) <- 1:27

student_attributes <- read_excel("data/student-attributes.xlsx")

student_matrix <- as.matrix(student_friends)


student_network <- as_tbl_graph(student_matrix, 
                                directed = TRUE)

student_edges <- read_excel("data/student-edgelist.xlsx")

student_network <- as_tbl_graph(student_matrix, 
                                directed = TRUE)
student_network <- tbl_graph(edges = student_edges,             nodes = student_attributes, directed = TRUE)

ggraph(student_network, layout = "stress") + 
  geom_edge_link(arrow = arrow(length = unit(1, 'mm')), 
                 end_cap = circle(3, 'mm'),
                 start_cap = circle(3, 'mm'),
                 alpha = .2) +
  geom_node_text(aes(label = id),
                 repel=TRUE) +
  geom_node_point(aes(size = local_size(),
                      color = achievement))

```

## Row

### Teacher Reported Friendships {data-width="350"}

```{r}

teacher_friends <- read_excel("data/teacher-reported-friends.xlsx", col_names = FALSE)

rownames(teacher_friends) <- 1:27

colnames(teacher_friends) <- 1:27

teacher_matrix <- as.matrix(teacher_friends)

teacher_network <- as_tbl_graph(teacher_friends)

teacher_edges <- teacher_network |>
  activate(edges) |>
  as_tibble()


teacher_network <- as_tbl_graph(teacher_matrix, 
                                directed = TRUE)

teacher_network <- tbl_graph(edges = teacher_edges, 
                             nodes = student_attributes , 
                             directed = TRUE )

ggraph(teacher_network, layout = "stress") + 
  geom_edge_link(arrow = arrow(length = unit(1, 'mm')), 
                 end_cap = circle(3, 'mm'),
                 start_cap = circle(3, 'mm'),
                 alpha = .2) +
  geom_node_text(aes(label = id),
                 repel=TRUE) +
  geom_node_point(aes(size = local_size(),
                      color = achievement))
```