---
title: "An Analysis of Grade Data in In-Person vs Online Course Delivery"
author: "Sean Student"
date: "Current Semester"
output:
  pdf_document: default
  html_document:
    df_print: paged
---

## Introduction

This report compares the performance of students, as measured by final grades, in the same course taught in-person during the Spring term and online in the Fall term. All assignments, lectures, materials, and assessments were identical between both terms.

## Analysis

```{r loadCSV, echo=F}
df <- read.csv("https://s3.us-east-2.amazonaws.com/artificium.us/datasets/Grades.csv",
               header = T)

fall <- which(df$Term == "Fall")
spring <- which(df$Term == "Spring")
n.Fall <- length(fall)
n.Spring <- length(spring)

n.ByInstructor <- table(df$Instructor)

mean.Spring <- mean(df$Score[spring])
median.Spring <- median(df$Score[spring])
sd.Spring <- sd(df$Score[spring])
min.Spring <- min(df$Score[spring])
max.Spring <- max(df$Score[spring])

mean.Fall <- mean(df$Score[fall])
median.Fall <- median(df$Score[fall])
sd.Fall <- sd(df$Score[fall])
min.Fall <- min(df$Score[fall])
max.Fall <- max(df$Score[fall])
```

The course CS1000 was taken during the Spring term by `r n.Spring` students and by `r n.Fall` in the Fall. The Spring course was delivered using a traditional in-situ and in-person modality, while the in the Fall the course was delivered using a synchronous online modality.

The breakdown of students by instructor was as follows[^1]:

[^1]: The grouping was performed using the R function `table()`.

```{r, comment="", echo=F}
print(n.ByInstructor)
```

The mean grade during the Spring was `r round(mean.Spring,1)` ($\sigma$ = `r round(sd.Spring,2)`) with a median of `r round(median.Spring,1)`, while the mean grade during the fall was `r round(mean.Fall,1)` ($\sigma$ = `r round(sd.Fall,2)`) with a median of `r round(median.Fall,1)`. The mean grade for the Fall term was `r round(mean.Fall - mean.Spring,1)` points higher.

The grades ranged from `r round(min.Spring,1)` to `r round(max.Spring,1)` in the Spring and from `r round(min.Fall,1)` to `r round(max.Fall,1)` in the Fall[^2].

[^2]: Grades range from 0 to 100, but can be above 100 as bonus points were earned by some students.

```{r testNormality, echo=F}
sw.Spring <- shapiro.test(df$Score[spring])
sw.Fall <- shapiro.test(df$Score[fall])
```

To evaluate whether the difference in means is statistically significant requires determining whether the distribution of both sets of grades is reasonably normal so that the appropriate hypothesis test can be applied. 

A Shapiro-Wilk test for both Spring and Fall grades showed that they are not normally distributed (_W~Spring~_ = `r round(sw.Spring$statistic[[1]],3)`, _W~Fall~_ = `r round(sw.Fall$statistic[[1]],3)`, _p_ < 0.05 for both data sets).

A histogram shows that the combined set of grades is right skewed, as illustrated below:

```{r plotGradeHisto, echo=F}
hist(df$Score,
     main = "Histogram of Final Grades",
     xlab = "Grades",
     col = "navy")
```

```{r Wilcoxon, echo=F}
w <- wilcox.test(df$Score[spring], df$Score[fall])
```

A non-parametric Wilcoxon test showed that the difference in scores is statistically significant (_p < 0.05_, _W = `r w$statistic[[1]]`_).

## Conclusion

An analysis of final grades demonstrated that average student performance in an online modality was higher than in a traditional setting, although the ranges of scores were wider in the online course, which may indicate that some students may not perform well in that modality.
