n1 = 125
n2 = 125
x1 = 62
x2 = 41
alpha = 0.05
p1 = x1/n1
p2 = x2/n2
#pooled p under Ho that two proportions are equal
p = (p1*n1+p2*n2)/(n1 + n2) # same number we got before
SE = sqrt(p * ( 1 - p ) * ((1/n1) + (1/n2)))
Zstat = (p1-p2)/SE
Zstat
## [1] 2.698435
#corrected Zstat = 2.698
# p-value for a two-tailed test
2*pnorm(-2.698)
## [1] 0.006975744
# p-value is ~ .007 -> reject Ho; treatments are different
Resulted generated by machine for both, they are in the F-table. Should be right.
Assumptions: 1. The sampling method for each sample is simple random sampling. CHECK
The samples are independent. CHECK
Each population is at least 20 times larger than its respective sample. # CHECK (assume tht there are at least 750 students in the university)
The sampling distribution is approximately normal, which is generally the case if any of the following conditions apply.
The population distribution is normal. NO
The population data are symmetric, unimodal, without outliers, and the sample size is 15 or less. NO
The population data are slightly skewed, unimodal, without outliers, and the sample size is 16 to 40. YES
The sample size is greater than 40, without outliers. NO
## calculate the means and standard deviations of each group
day_age = c(22, 24, 24, 23, 19, 19, 23, 22, 18, 21, 21,
18, 18, 25, 29, 24, 23, 22, 22, 21, 20, 20,
20, 27, 17, 19, 18, 21, 20, 23, 26)
night_age = c(18, 20, 25, 23, 20, 24, 25, 23, 23, 23, 19,
25, 20, 21, 24, 19, 23, 27, 23, 24, 23, 24,
20, 21, 20, 24, 21, 21, 20, 28, 27)
n_d = length(day_age)
n_n = length(night_age)
x_bar_d <- mean(day_age)
x_bar_n <- mean(night_age)
s_d <- sd(day_age)
s_n <- sd(night_age)
#Hypotheses: Ho: μ1 - μ2 = 0, Ha: μ1 - μ2 ≠ d
# alternatve is that there is a difference between day and night student ages
alpha = .01
SE = sqrt((s_d^2/n_d) + (s_n^2/n_n))
df = min(n_d-1,n_n-1)
tstat = (x_bar_d-x_bar_n)/SE
tstat
## [1] -1.361137
# t-statistic is -1.361
p_value = 2*pt(-1.361, df)
p_value
## [1] 0.1836505
# p_value is > alpha so DO NOT REJECT Ho There is not evidence to support the claim that day and night students are different ages.