Showing posts with label Two Sample t-test. Show all posts
Showing posts with label Two Sample t-test. Show all posts

Sunday, August 25, 2019

Two Sample t-test

Two sample t-test

t-test,sample,two-sample t-test,student's t-test,two sample t test,one sample t-test,two sample t test in r,2 sample t test,two sample,two sample t test example,ttest,two sample t test r,two sample test r,two sample t test in r code,two sample hypothesis test,two sample t test in r studio,two sample hypothesis tests,single sample t-test,two,two sample confidence intervals,paired samples

x = c(70, 82, 78, 74, 94, 82) 
> n = length(x)
> m=8 observation of y
"m=8 observation"
> y = c(64, 72, 60, 76, 72, 80, 84, 68)
> m = length(y)
> we will test H0 : µ1 = µ2 versus H1 : µ1 > µ2.
> x_bar = mean(x)
> s_x = sd(x)
> y_bar = mean(y)
> s_y = sd(y)
> s_p = sqrt(((n - 1) * s_x ^ 2 + (m - 1) * s_y ^ 2) / (n + m - 2))
> t = ((x_bar - y_bar) - 0) / (s_p * sqrt(1 / n + 1 / m))
> t
[1] 1.823369
> 1 - pt(t, df = n + m - 2)
[1] 0.04661961
> t.test(x, y, alternative = c("greater"), var.equal = TRUE)

Two Sample t-test


data:  x and y
t = 1.8234, df = 12, p-value = 0.04662
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
 0.1802451       Inf
sample estimates:
mean of x mean of y 
       80        72  
> t_test_data = data.frame(values = c(x, y), group = c(rep("A", length(x)), rep("B", length(y))))
> t_test_data
   values group
1      70     A
2      82     A
3      78     A
4      74     A
5      94     A
6      82     A
7      64     B
8      72     B
9      60     B
10     76     B
11     72     B
12     80     B
13     84     B
14     68     B
> t.test(values ~ group, data = t_test_data, alternative = c("greater"), var.equal = TRUE)

https://youtu.be/DwKq404Q0Gk