\[\bar{X_1} - \bar{X_2} \sim N \left( \mu_1-\mu_2, \sqrt{\frac{(\sigma_1)^2}{n_1} + \frac{(\sigma_2)^2}{n_2}} \right) \]
When the population standard deviation is unknown for both groups, we use the sample standard deviation and the \(t\)-distribution with degrees of freedom equal to the smaller of \(n_1-1\) and \(n_2-1\).
\(H_0: \mu_T = \mu_C\)
\(H_A: \mu_T < \mu_C\)
true_diff <- 0
observed_diff <- (-4)- (-1.4)
se <- sqrt(5.2^2/9 + 2.4^2/9)
# find the standarized score: t-score
t <- (observed_diff - true_diff)/se
pt(t,8)
## [1] 0.1051635
# our p-value is .105, so our observed difference is not very rare
# since our p-value of .105 is not smaller than the significance level of .05, we fail to reject the null hypothesis.
# since our p-value of .105 is not smaller than the significance level of .05, there is not statistically significant evidence that the medication works.
\(H_0: \mu_B = \mu_G\)
\(H_A: \mu_B \neq \mu_G\)
true_diff <- 0
observed_diff <- 3.22 - 2
se <- sqrt(1^2/16 + .866^2/9)
# find t-score
t <- (observed_diff - true_diff)/se
(1-pt(t,8))*2
## [1] 0.01271201
# our p-value is .0127
# since our p-value of .0127 is smaller than the significance level of .05, we reject the null hypothesis
# there is statistically significant evidence that the average amount of time the groups spend watching tv is different.
\[\hat{p_1} - \hat{p_2} \sim N \left( p_1- p_2, \sqrt{ \frac{p_1(1-p_1)}{n_1} + \frac{p_2(1-p_2)}{n_2}} \right) \]
College Grad | Not College Grad | |
---|---|---|
Support | \(154\) | \(132\) |
Oppose | \(180\) | \(126\) |
Don’t know | \(104\) | \(131\) |
Total | \(438\) | \(389\) |
\(H_0: p_c = p_n\)
\(H_A: p_c \neq p_n\)
phat_c <- 154/438
phat_n <- 132/389
# since we are assuming p_c=p_n we need to use a pooled proportion
pooled <- (154+132)/(438+389)
# check the success-failure condition
# the number of success in the college grad group
pooled*438
## [1] 151.4728
# the number of failure in the college grad group
(1-pooled)*438
## [1] 286.5272
# the number of success in the non-college grad group
pooled*389
## [1] 134.5272
# the number of failure in the non-college grad group
(1-pooled)*389
## [1] 254.4728
# all bigger than 10, so conditions are satisfied
observed_diff <- phat_c-phat_n
true_diff <- 0
se <- sqrt(pooled*(1-pooled)/438 + pooled*(1-pooled)/389)
# find the z-score
z<-(observed_diff - true_diff)/se
(1-pnorm(z))*2
## [1] 0.7112531
# Since our p-value is big, this data is not rare, we have no reason to reject the null
# since the p-value of .71 is bigger than the significance level of .05, we fail to reject the null