This notebook analyzes and compares ACT scores for male and female undergraduate student populations at University of Wisconsin - Eau Claire (UWEC). The data provided by the professor is a sample of 200 students from the total population. The steps below follow the instructions from the “Focusing on Data Analysis” section at the end of Chapter 10 of the textbook “Introductory Statistics”, 10th Edition, by Neil A. Weiss.
Load R packages:
library(xlsx)
library(tidyr)
library(stringr)
library(dplyr)
library(ggplot2)
library(gridExtra)
library(knitr)Read in the sample data provided by the professor:
focusSample <- read.xlsx("../FocusSample.xls", sheetIndex=1, header=TRUE)Part A
Obtain normal probability plots, boxplots, and the sample standard deviations of the ACT composite scores for the sampled males and the sampled females.
Only the gender, composite ACT scores, and the cumulative GPA are needed for each student to complete the requested analyses in parts A-D, so just pull in those columns. Also, make this dataset “tidy” by gathering the various scores columns into a single score column with a score type column.
atodSample <-
focusSample %>%
select(one_of(c("SEX", "GPA", "COMP"))) %>%
gather(scoreType, score, GPA:COMP)
kable(head(atodSample))Calculate the summary statistics (mean, standard deviation, count) for each sex and score-type subgroup
summaryStats <-
atodSample %>%
group_by(SEX, scoreType) %>%
summarize(mean = mean(score), stddev = sd(score), count =n()) %>%
arrange(scoreType)
kable(summaryStats, digits=2)| SEX | scoreType | mean | stddev | count |
|---|---|---|---|---|
| F | COMP | 23.61 | 2.92 | 118 |
| M | COMP | 23.93 | 3.43 | 82 |
| F | GPA | 3.00 | 0.49 | 118 |
| M | GPA | 2.90 | 0.54 | 82 |
Conclusions that can be drawn from these statistics:
Both the male and female sample sizes are large (>>30), so we can assume that the sample means are normally distributed.
The ratio of the standard deviations in the COMP scores of the male to female samples is 1.18. This is sufficiently close to use the assumption that the population standard deviations are equal.
Next we display the female and male normal probability plots for the ACT composite scores. These should confirm that the male and female samples are normally distributed (is that the correct language?).
femaleSample <- filter(atodSample, SEX=="F", scoreType=='COMP')
ggFemale <- ggplot(femaleSample, aes(sample=score)) +
ggtitle("Female ACT Composite Q-Q Plot") +
ylab("ACT COMP Score") +
coord_cartesian(ylim=c(16,33))
qqFemale <- ggFemale + stat_qq()
maleSample <- filter(atodSample, SEX=="M", scoreType=='COMP')
ggMale <- ggplot(maleSample, aes(sample=score)) +
ggtitle("Male ACT Composite Q-Q Plot") +
ylab("ACT COMP Score") +
coord_cartesian(ylim=c(16,33))
qqMale <- ggMale + stat_qq()
grid.arrange(qqFemale, qqMale, ncol=2)The linear appearance of these QQ-plots confirms that the male and female samples are normally distributed (really?).
Next we compare boxplots of the ACT composite score for both gender samples.
compSample <- filter(atodSample, scoreType=='COMP')
bp <- ggplot(compSample, aes(SEX, score, fill=SEX)) +
ggtitle("ACT Composite BoxPlot") +
ylab("ACT COMP Score") +
stat_boxplot()
grid.arrange(bp)Again, we observe that the sample distributions are similar.
Part B
At the 5% significance level, do the data provide sufficient evidence to conclude that mean ACT composite scores differ for male and female UWEC undergraduates? Justify the use of the procedure you chose to carry out the hypothesis test.
Based on the information learned about the samples in Part A, we are justified in using the Pooled t-Test procedure to perform the hypothesis test in Part B. In particular:
- The two gender samples are independent and simple random (as stated in Chapter 1, page 34).
- The composite ACT score is a normally distributed variable on each of the two gender populations, or we have large samples (n>30). Here we have n>>30.
- The population standard deviations are equal (based on the sample standard deviations being within 20% of each other)
Pooled t-Test Procedure
Step 1:
Null hypothesis: \(H_{0}\): \(\mu_{f}\) - \(\mu_{m}\) = 0 (The mean composite scores do not differ for male and female UWEC undergraduates)
Alternative hypothesis: \(H_{a}\): \(\mu_{f}\) - \(\mu_{m}\) \(\neq\) 0 (The mean composite scores differ for male and female UWEC undergraduates)
Step 2:
Significance level \(\alpha\) = 0.05
Steps 3/4:
result <- t.test(femaleSample$score, maleSample$score,
alternative="two.sided", var.equal=TRUE, conf.level=0.95)The test result returned a p-value of 0.484.
Step 5:
Because p-value > \(\alpha\), do not reject the null hypothesis.
Step 6:
At the 5% significance level, the data do not provide sufficient evidence to conclude that mean ACT composite scores differ for male and female UWEC undergraduates.
Part C
Determine and interpret a 95% confidence interval for the difference between the mean ACT composite scores of male and female UWEC undergraduates.
The 95% confidence interval can be retrieved from the result of the pooled t-test in Part B (the t.test return value), since that t-test was done for an confidence level of 95%.
We can be 95% confident that the difference between mean composite ACT scores of female and male undergraduate UWEC students is somewhere between -1.21 and 0.57.
Part D
Repeat parts A-C for cumulative GPA.
The summary statistics of Part A can be re-used here. Again, the sample sizes of male and female undergraduates are sufficiently large that we can assume the mean scores are normally distributed. The ratio of the GPA standard deviations of male to female is 1.09, which again allows us to assume the population standard deviations are equal.
Next we display the female and male normal probability plots for the GPA scores. These should confirm that the male and female samples are normally distributed (is that the correct language?).
femaleSample <- filter(atodSample, SEX=="F", scoreType=='GPA')
ggFemale <- ggplot(femaleSample, aes(sample=score)) +
ggtitle("Female GPA Q-Q Plot") +
ylab("GPA Score") +
coord_cartesian(ylim=c(1.5,4))
qqFemale <- ggFemale + stat_qq()
maleSample <- filter(atodSample, SEX=="M", scoreType=='GPA')
ggMale <- ggplot(maleSample, aes(sample=score)) +
ggtitle("Male GPA Q-Q Plot") +
ylab("GPA Score") +
coord_cartesian(ylim=c(1.5,4))
qqMale <- ggMale + stat_qq()
grid.arrange(qqFemale, qqMale, ncol=2)These plots show approximately linear result, confirming that the sample data is approximately normally distributed.
Next we compare boxplots of the GPA score for both gender samples.
compSample <- filter(atodSample, scoreType=='GPA')
bp <- ggplot(compSample, aes(SEX, score, fill=SEX)) +
ggtitle("GPA Score BoxPlot") +
ylab("GPA Score") +
stat_boxplot()
grid.arrange(bp)Based on the information learned above about the samples, we are again justified in using the Pooled t-Test procedure to perform the hypothesis test. In particular:
- The two gender samples are independent and simple random (as stated in Chapter 1, page 34).
- The GPA score is a normally distributed variable on each of the two gender populations, or we have large samples (n>30). Here we have n>>30.
- The population standard deviations are equal (based on the sample standard deviations being within 10% of each other)
Pooled t-Test Procedure
Step 1:
Null hypothesis: \(H_{0}\): \(\mu_{f}\) - \(\mu_{m}\) = 0 (The mean GPA scores do not differ for male and female UWEC undergraduates)
Alternative hypothesis: \(H_{a}\): \(\mu_{f}\) - \(\mu_{m}\) \(\neq\) 0 (The mean GPA scores differ for male and female UWEC undergraduates)
Step 2:
Significance level \(\alpha\) = 0.05
Steps 3/4:
result <- t.test(femaleSample$score, maleSample$score,
alternative="two.sided", var.equal=TRUE, conf.level=0.95)The test result returned a p-value of 0.179.
Step 5:
Because p-value > \(\alpha\), do not reject the null hypothesis.
Step 6:
At the 5% significance level, the data do not provide sufficient evidence to conclude that mean GPA scores differ for male and female UWEC undergraduates.
The 95% confidence interval can be retrieved from the result of the pooled t-test above (the t.test return value), since that t-test was done for an confidence level of 95%.
We can be 95% confident that the difference between mean GPA scores of female and male undergraduate UWEC students is somewhere between -0.05 and 0.25.
Part E
Obtain a normal probability plot, boxplot, and histogram of the paired differences of the ACT English scores and ACT math scores for the samplled UWEC undergraduates.
Only the difference between the English and Math ACT scores for each student are needed to complete the requested analyses in parts E-I, so we filter for those scores, and then “mutate” a new column containing the difference of English and Math.
etoiSample <-
focusSample %>%
select(one_of(c("MATH", "ENGLISH"))) %>%
mutate(diff = ENGLISH - MATH)Calculate the summary statistics (mean, standard deviation, count) of the difference between English and Math scores.
summaryStats <-
etoiSample %>%
summarize(meanD = mean(diff), sdD = sd(diff), count =n())
kable(summaryStats, digits=2)| meanD | sdD | count |
|---|---|---|
| -0.4 | 4.15 | 200 |
Conclusions that can be drawn from these statistics:
The paired samples are simple random (as stated in Chapter 1, page 34).
The sample size is large (>>30), so we can assume that the sample mean is normally distributed.
Next the normal probability plot is shown to demonstrate the approimate normality of paired difference score for the sample.
ggDiff <- ggplot(etoiSample, aes(sample=diff)) +
ggtitle("English-Math Score Difference Q-Q Plot") +
ylab("English-Math Difference Score") +
coord_cartesian(ylim=c(-10, 10))
ggDiff <- ggDiff + stat_qq()
grid.arrange(ggDiff)The linear appearance of these QQ-plot confirms that the paired difference scores for the sample are approximately normally distributed (really?).
Next the boxplot is shown.
bp <- ggplot(etoiSample, aes(factor(0), diff)) +
ggtitle("English-Math Score Difference BoxPlot") +
ylab("English-Math Difference Score") +
xlab("") + scale_x_discrete(breaks = NULL) +
stat_boxplot()
grid.arrange(bp)Lastly, this histogram for the same data.
bp <- ggplot(etoiSample, aes(diff)) +
ggtitle("English-Math Score Difference Histogram") +
xlab("English-Math Difference Score") + ylab("Count") +
geom_histogram(binwidth = 1)
grid.arrange(bp)Part F
At the 5% significance level, do the data provide sufficient evidence to conclude that, for UWEC undergraduates, the mean ACT English score is less than the mean ACT math score? Justify the use of the procedure you chose to carry out the hypothesis test.
The Math and English scores for each student are a paired sample, with the pair being one population of students that took the Math ACT and one population of students that took the English ACT. The sample we are given is simple random, and it contains a large sample n>>30.
Thus we are justified in using a paired t-test, and that is equivalent to a one-mean t-test of the paired-difference variable (the diff column in the etoiSample).
One-Mean t-Test Procedure
Step 1:
Null hypothesis: \(H_{0}\): \(\mu_{e}\) - \(\mu_{m}\) = 0 (The mean Math and English scores do not differ for UWEC undergraduates)
Alternative hypothesis: \(H_{a}\): \(\mu_{e}\) - \(\mu_{m}\) \(\lt\) 0 (The mean English score is less than the mean Math score for UWEC undergraduates)
Step 2:
Significance level \(\alpha\) = 0.05
Steps 3/4:
result <- t.test(etoiSample$diff,
alternative="less", conf.level=0.95)The test result returned a p-value of 0.09.
Step 5:
Because p-value > \(\alpha\), do not reject the null hypothesis.
Step 6:
At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean ACT English score is less than the mean ACT math score for UWEC undergraduates.
Part G
Repeat part F at the 10% significance level.
Step 1:
Same as previous: Null hypothesis: \(H_{0}\): \(\mu_{m}\) - \(\mu_{e}\) = 0 (The mean Math and English scores do not differ for UWEC undergraduates)
Alternative hypothesis: \(H_{a}\): \(\mu_{e}\) - \(\mu_{m}\) \(\lt\) 0 (The mean English score is less than the mean Math score for UWEC undergraduates)
Step 2:
Significance level \(\alpha\) = 0.10
Steps 3/4:
result <- t.test(etoiSample$diff,
alternative="less", conf.level=0.90)The test result returned a p-value of 0.09. This is the same result as found previously, because the p-value does not depend on the value of \(\alpha\) (but its interpretation in Step 5 certainly does!).
Step 5:
Because p-value < \(\alpha\), reject the null hypothesis.
Step 6:
At the 10% significance level, the data do provide sufficient evidence to conclude that the mean ACT English score is less than the mean ACT math score for UWEC undergraduates.
Part H
Find and interpret a 90% confidence interval for the difference between the mean ACT English score and the mean ACT math score of UWEC undergraduates.
The 90% confidence interval can be retrieved from the result of the pooled t-test in Part G (the t.test return value), since that t-test was done for an confidence level of 90%.
We can be 90% confident that the difference between the mean ACT English score and the mean ACT math score of UWEC undergraduates is less than -0.02.
Part I
Repeat part H, using an 80% confidence level.
To obtain the 80% confidence interval we rerun the t.test with conf.level = 0.80, and get the uppper limit of the confidence interval from that result.
result <- t.test(etoiSample$diff,
alternative="less", conf.level=0.80)We can be 80% confident that the difference between the mean ACT English score and the mean ACT math score of UWEC undergraduates is less than -0.15. That is, the upper limit of the difference is more negative with lesser confidence.