#Overview: This document will discuss the differences in subject scores for high school students based on gender and race.
#Introduction: The dataset used for the document is the hsb2 dataset from the ‘openintro’ library in R. This dataset was performed by the National Center of Education Statistics, and was published by the UCLA institute for Digital Research & Education - Statistical Consulting.
#Exploring the data
#store the dataset
library(openintro)
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
hsb2 <- hsb2
#summary
summary(hsb2)
## id gender race ses
## Min. : 1.00 Length:200 Length:200 low :47
## 1st Qu.: 50.75 Class :character Class :character middle:95
## Median :100.50 Mode :character Mode :character high :58
## Mean :100.50
## 3rd Qu.:150.25
## Max. :200.00
## schtyp prog read write math
## public :168 general : 45 Min. :28.00 Min. :31.00 Min. :33.00
## private: 32 academic :105 1st Qu.:44.00 1st Qu.:45.75 1st Qu.:45.00
## vocational: 50 Median :50.00 Median :54.00 Median :52.00
## Mean :52.23 Mean :52.77 Mean :52.65
## 3rd Qu.:60.00 3rd Qu.:60.00 3rd Qu.:59.00
## Max. :76.00 Max. :67.00 Max. :75.00
## science socst
## Min. :26.00 Min. :26.00
## 1st Qu.:44.00 1st Qu.:46.00
## Median :53.00 Median :52.00
## Mean :51.85 Mean :52.41
## 3rd Qu.:58.00 3rd Qu.:61.00
## Max. :74.00 Max. :71.00
#head function
head(hsb2)
## # A tibble: 6 × 11
## id gender race ses schtyp prog read write math science socst
## <int> <chr> <chr> <fct> <fct> <fct> <int> <int> <int> <int> <int>
## 1 70 male white low public general 57 52 41 47 57
## 2 121 female white middle public vocational 68 59 53 63 61
## 3 86 male white high public general 44 33 54 58 31
## 4 141 male white high public vocational 63 44 47 53 56
## 5 172 male white middle public academic 47 52 57 53 61
## 6 113 male white middle public academic 44 52 51 63 61
With 200 observations of 11 variables, ‘hsb2’ can be organized into two sections of variables. First are the variables about the backgrounds of the students (of which all are high school seniors). In this section, we see things like socioeconomic status, school type (whether it is public or private), and what program the students are involved in (whether it is general, academic, or vocational). although the only variables useful to us are gonna be those focusing on gender and race. The second section of variables are school subjects with their entries being scores on a standardized test relating to that subject. it is worth noting that the scores for these variables do not exceed 76 and in the case of writing do not exceed 67, so we can assume that this standardized test is not scored on a percentage system.
#Analysis part I
For the first segment of the analysis we will be focusing on the subject of gender. We will be attempting to disprove the null hypothesis that the male and female genders perform the same in each subject. The alternative hypothesis is that the male and female genders perform differently in those same subjects. All of this is given an alpha of 0.05.
#dividing the data
male <- subset(hsb2, gender == "male")
female <- subset(hsb2, gender == "female")
#two sided t-test on both genders based on all subjects
t.test(male$read, female$read)$p.value
## [1] 0.457161
t.test(male$write, female$write)$p.value
## [1] 0.0003408849
t.test(male$math, female$math)$p.value
## [1] 0.6815673
t.test(male$science, female$science)$p.value
## [1] 0.07602685
t.test(male$socst, female$socst)$p.value
## [1] 0.4656103
So the results from the gender section of the analysis reveal four p-values that go above the value of 0.05 with 3 of those values by a significant margin. The four p-values suggest that we fail to reject the null hypothesis. Therefore, there is not enough evidence to declare a difference in the subjects reading, math, science, and social studies. Writing shares a different story in which the p-value is under 0.05 by a significant margin, which means that we reject the null hypothesis, and that there is significant data to state that there is a difference in performance among writing scores.
#Analysis part II
This second segment focuses on race instead of gender, so we shall hold a similar hypothesis test in which the null hypothesis states that there is no difference and the alternative hypothesis is that there is at least one difference. Once again, the alpha value will still be 0.05.
#dividing the data
asian <- subset(hsb2, race == "asian")
afamerican <- subset(hsb2, race == "african american")
hispanic <- subset(hsb2, race == "hispanic")
white <- subset(hsb2, race == "white")
unlist(summary(aov(read ~ race, data = hsb2)))[9]
## Pr(>F)1
## 0.0006538515
format(unlist(summary(aov(write ~ race, data = hsb2)))[9],scientific = FALSE)
## Pr(>F)1
## "0.00005784516"
format(unlist(summary(aov(math ~ race, data = hsb2)))[9],scientific = FALSE)
## Pr(>F)1
## "0.00006840199"
format(unlist(summary(aov(science ~ race, data = hsb2)))[9],scientific = FALSE)
## Pr(>F)1
## "0.00000002561595"
format(unlist(summary(aov(socst ~ race, data = hsb2)))[9],scientific = FALSE)
## Pr(>F)1
## "0.04098048"
This time, the analysis did not wield any different results, all of the p-values ended up below the alpha of 0.05. Thus, we fail to reject the null hypothesis and state that there is not enough evidence to prove that race has an affect on the scores of students.
#Conclusions The ‘hsb2’ data set shows us that although race has no affect on the scores of a student, gender does manage to play a role in the scores of writing and not much else.
#Limitations The sample for ‘hsb2’ is quite small with only 200 entries, and although the sample does have students from a variety of backgrounds both economically and socially, the data may not be representative of the large number of students within the US.
This document was produced as a final project for MAT 143H -
Introduction to Statistics (Honors) at North Shore Community
College.
The course was led by Professor Billy Jackson.
Student Name: Matthew Blackman Semester: Spring 2024