\[ n_1=28 \]
\[ n_2=22 \]
I will use function mean
.
I am given -
n1 <- 28
n2 <- 22
x1_bar <- 1025
x2_bar <- 910
s1 <- 150
s2 <- 125
I need to compute my test statistic and compare it with my critical value
se <- sqrt( (s1^2 / n1) + (s2^2 / n2) )
se
## [1] 38.90757
test_stat <- ((x1_bar - x2_bar) - 0)/se
test_stat
## [1] 2.955723
df_n <- se^4
df_d <- ( s1^2/n1 )^2/( n1-1 ) + ( s2^2/n2 )^2/( n2-1 )
df <- df_n/df_d
alpha <- .05
critical_value <-
qt(p = alpha/2,
df = df,
lower.tail = FALSE
)
Reject the null that no difference between the two means.
alpha
## [1] 0.05
p_value <- 2 * pt(q = test_stat,
df = df,
lower.tail = FALSE
)
p_value < alpha
## [1] TRUE
CI should not include the hypothesized value of 0.
MOE <- qt(p = 1-alpha/2,
df = df) * se
upper_bound <- (x1_bar - x2_bar) + MOE
lower_bound <- (x1_bar - x2_bar) - MOE
lower_bound
## [1] 36.76286
upper_bound
## [1] 193.2371