#install.packages("tinytex")

This assignment applies hypothesis testing concepts to two problems: comparing proportions (AP exam participation) and comparing means (infant crying time).

For each question: - Write the hypothesis tests.
- State the significance level (\(\alpha\)).
- Report the p-value.
- State your decision.


Problem 1: Two-Proportion Z-Test (AP Exam Participation)

Many high school students take the AP tests in different subject areas.
In 2017, of the 144,790 students who took the Biology exam, 84,200 were female.
Of the 211,693 students who took the Calculus AB exam, 102,598 were female.

Is there enough evidence to show that the proportion of female students taking the Biology exam is higher than the proportion of female students taking the Calculus AB exam?
Test at the 5% level.


Hypotheses

\(H_0\): \(p_{Bio} = p_{Calc}\)
\(H_a\): \(p_{Bio} > p_{Calc}\)


Significance Level

\(\alpha = 0.05\)


R Code

bio_total <- 144790
bio_female <- 84200

calc_total <- 211693
calc_female <- 102598

prop.test(c(bio_female, calc_female),
           c(bio_total, calc_total),
           alternative = "greater",
           correct = FALSE)
## 
##  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

p-value and Decision

Using the output of the test:

If p-value < 0.05, reject \(H_0\).

If p-value ≥ 0.05, fail to reject \(H_0\).

At \(\alpha = 0.05\), the result determines whether there is sufficient evidence that the proportion of female Biology AP exam takers is higher than that of Calculus AB.

p-value < 2.2 × 10⁻¹⁶ (< 0.05) Therefore, we reject \(H_0\). There is very strong statistical evidence that the proportion of female students taking the Biology AP exam is higher than the proportion of female students taking the Calculus AB exam. The estimated proportions are \(p_{Bio}=0.5815\) and \(p_{Calc}=0.4847\), with a 95% confidence interval for their difference of (0.094, 1.00).

Decision Example: If p-value = 0.017 < 0.05 → Reject \(H_0\). There is sufficient evidence that a higher proportion of female students took the Biology AP exam compared to Calculus AB.

Problem 2: Two-Sample t-Test (Infant Crying Time After Vitamin K Shot) A vitamin K shot is given to infants soon after birth. The study aims to see if how the infants are handled could reduce the pain the infants feel.

Two groups were tested:

Conventional method (infants laid down)

New method (infants held by their mothers)

We measure how long (in seconds) each infant cried after receiving the shot. Is there enough evidence to show that infants cry less when held by their mothers than when handled conventionally? Test at the 5% level.

Data

#Crying time (seconds) - Conventional Method
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
)

#Crying time (seconds) - New Method (Mother Holding Infant)

held <- 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
)

Hypotheses

\(H_0\): \(\mu_{held} = \mu_{conv}\) \(H_a\): \(\mu_{held} < \mu_{conv}\)

Significance Level

\(\alpha = 0.05\)

R Code

t.test(held, conventional,
       alternative = "less",
       var.equal = FALSE,
       conf.level = 0.95)
## 
##  Welch Two Sample t-test
## 
## data:  held 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

p-value and Decision

Decision rule:

If p-value < 0.05, reject \(H_0\).

If p-value ≥ 0.05, fail to reject \(H_0\).

Interpretation: If the p-value is less than 0.05, there is sufficient evidence that infants cry less, on average, when held by their mothers compared to when handled using conventional methods.

If the p-value is greater than 0.05, there is not enough evidence to conclude that being held reduces crying time.

Confidence Interval

The test output also provides a 95% confidence interval for the mean difference \((\mu_{held} - \mu_{conv})\).

If the confidence interval lies entirely below 0, it supports the claim that infants held by their mothers cry for a shorter time. If the interval includes 0, there is no significant difference between the two groups.

Interpretation

p-value = 0.4881 (> 0.05) Fail to reject \(H_0\). There is no statistically significant evidence that infants cry less when held compared to conventional handling.

95% Confidence Interval: (−∞, 9.135) Includes 0 → difference could be zero.

Conclusion: Average crying times (35.13s vs. 35.30s) are nearly identical, suggesting no meaningful effect from the holding method.