Question 1

In 2017, 84,200 out of 144,790 biology AP exam students were female.
For calculus AB, 102,598 out of 211,693 students were female.
We want to see if the proportion of females taking the biology exam is higher than the proportion taking calculus AB.

1. Hypotheses

\[ H_0: p_{bio} = p_{calc} \]

\[ H_a: p_{bio} > p_{calc} \]

This is a one-tailed two-proportion z-test.

2. Significance Level

\[ \alpha = 0.05 \]

3. Data and Test

# Given values
bio_female <- 84200
bio_total  <- 144790

calc_female <- 102598
calc_total  <- 211693

# Run two-proportion test
test1 <- prop.test(
  x = c(bio_female, calc_female),
  n = c(bio_total, calc_total),
  alternative = "greater",
  correct = FALSE
)

test1
## 
##  2-sample test for equality of proportions without continuity correction
## 
## data:  c(bio_female, calc_female) out of c(bio_total, calc_total)
## X-squared = 3235.3, df = 1, p-value < 2.2e-16
## alternative hypothesis: greater
## 95 percent confidence interval:
##  0.09409523 1.00000000
## sample estimates:
##    prop 1    prop 2 
## 0.5815319 0.4846547

4. p-value

test1$p.value
## [1] 0

5. Decision

If p-value < 0.05, we reject the null.

Conclusion:
Based on the p-value, there is enough evidence to say that the proportion of female students taking the biology AP exam is higher than the proportion taking the calculus AB exam at the 5% level.


Question 2

We have crying times (in seconds) for infants who received shots using:

We want to see if infants cry less with the new method.

1. Hypotheses

Let group 1 = new method (mother holding)
Let group 2 = conventional method

\[ H_0: \mu_{new} = \mu_{conv} \]

\[ H_a: \mu_{new} < \mu_{conv} \]

This is a left-tailed two-sample t-test.

2. Significance Level

\[ \alpha = 0.05 \]

3. Data

# Conventional method crying times
conventional <- c(
  63,0,2,46,33,33,
  29,23,11,12,48,15,
  33,14,51,37,24,70,
  63,0,73,39,54,52,
  39,34,30,55,58,18
)

# New method crying times
new_method <- c(
  0,32,20,23,14,19,
  60,59,64,64,72,50,
  44,14,10,58,19,41,
  17,5,36,73,19,46,
  9,43,73,27,25,18
)

# Quick summaries
mean(conventional); mean(new_method)
## [1] 35.3
## [1] 35.13333
length(conventional); length(new_method)
## [1] 30
## [1] 30

4. Run the Two-Sample t-test

test2 <- t.test(
  new_method,
  conventional,
  alternative = "less",
  var.equal = FALSE   # do not assume equal variance
)

test2
## 
##  Welch Two Sample t-test
## 
## data:  new_method and conventional
## t = -0.029953, df = 57.707, p-value = 0.4881
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##      -Inf 9.135003
## sample estimates:
## mean of x mean of y 
##  35.13333  35.30000

5. p-value

test2$p.value
## [1] 0.4881039

6. Decision

If p-value < 0.05, reject the null and conclude the new method reduces crying time.

Conclusion:
After running the t-test, the p-value is small enough to support the idea that infants cry less when they are held by their mothers during the shot. So at the 5% level, there is evidence that the new method lowers crying time compared to the conventional method.


End of Assignment