#1- 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 of them were female. In that same year, of the 211,693 students who took the calculus AB exam 102,598 of them 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.
Biology Exam
Number of female students: 84,200
Total students: 144,790
Calculus AB Exam
Number of female students: 102,598
#We are testing if the proportion of females in Biology is higher.
##Hypothesis## Ho:p{bio} = p{calc} #Proportion of females in the biologu exam is equal to the proportion of females taking the calculus AB exam
Ha: p{bio} > p{calc} #Proportion of females in the biologu exam is higher than proportion of females taking the calculus AB exam
Significance level = 0.05
P-value p^bio = 84200/144790 = 0.5816
p^calc = 102520/211693 = 0.4847
##Difference in proportions 0.5816 - 0.4847 = 0.0969
##Conclusion##
0.0969 > 0.05
##There is sufficicent evidence, at a 5% significance level, to conclude that the proportion of female students taking AP Biology exam is in fact higher than the proportion of female students taking AP Calc Exam.##
##2-… A vitamin K shot is given to infants soon after birth. The study is to see if how they handle the infants could reduce the pain the infants feel. One of the measurements taken was how long, in seconds, the infant cried after being given the shot. A random sample was taken from the group that was given the shot using conventional methods, and a random sample was taken from the group that was given the shot where the mother held the infant prior to and during the shot. Is there enough evidence to show that infants cried less on average when they are held by their mothers than if held using conventional methods? Test at the 5% level.##
#We are testing if there is sufficient evidence to show that infants cryless on average when held by their mothers than other conventional methods at a 5% significance level.
#Identitfy differences in means#
#Create “conventional” and “mother” tables from datasets provided* conventional = c( 63,0,2,46,33,33, #row 1 29,23,11,12,48,15, #row 2 33,14,51,37,24,70, #row 3 63,0,73,39,54,52,#row 4 39,34,30,55,58,18 #row 5 )
mother = 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 )
t_67res <- t.test(mother, conventional, alternative = “less”, var.equal = FALSE)
```
’’’ ###Summary Stats
library(readr) library(dplyr)
’’’
#Find mean, standard deviation, and length of both tables
mean_conv <- mean(conventional) sd_conv <- sd(conventional) n_conv <- length(conventional)
mean_mother <- mean(mother) sd_mother<- sd(mother) n_mother <- length(mother)
t_res <- t.test(mother, conventional, alternative = “less”, var.equal = FALSE) #performs two sample test
q2_results <- list( mean_conventional = mean_conv, sd_conventional = sd_conv, n_conventional = n_conv, mean_mother = mean_mother, sd_mother = sd_mother, n_mother = n_mother, t_test = t_res )
q2_results # results of Two sample t-test
’’’ ###Hypothesis###
Ho: μmother = μconv # mean of re testing if there no sufficient evidence to show that infants cry less on average when held by their mothers than other conventional methods, at a 5% significance level
Ha: μmother < μconv #there is sufficient evidence to show that infants cry less on average when held by their mothers than other conventional methods, at a 5% significance level
Significance level = 0.05
##P-value##
t_res$p.value #calculation for p-value
=0.4881039
##Conclusion## ###0.4881 > 0.05 We fail to Reject Ho###