![]() Note that the formula of Welch t-test is described here and the formula of Student t-test hereĬoursera - Online Courses and Specialization Data science The t-test can be performed as follow: res<-t.test(x, y, var.equal=TRUE) Therefore, we can use the classic t-test witch assume equality of the two variances. In conclusion, there is no significant difference between the variances of the two sets of data. It’s greater than the significance level alpha = 0.05. The following R code can be used : var.test(x,y)į = 0.8718, num df = 9, denom df = 9, p-value = 0.8414Īlternative hypothesis: true ratio of variances is not equal to 1 Thus, we’ll use F-test to test for differences in variances. However you have to check this assumption before using it. The argument “var.equal=TRUE” can be used to indicate to the t.test() function that the two samples have equal variances. Welch t-test is just an adaptation of t-test, and it is used when the two samples have possibly unequal variances. Therefore, Welch t-test is performed by default. Remember that independent t-test can be used only when the two sets of data follow a bivariate normal distributions with equal variances.īy default, the R t.test() function makes the assumption that the variances of the two groups of samples, being compared, are different. We can then reject the null hypothesis and conclude that women’s average weight is significantly different from men’s average weight with a p-value = 0.0053. The p-value of the test is 0.0053, which is less than the significance level alpha = 0.05. The confidence interval (conf.int) of the mean differences at 95% is also shown (conf.int= ) and finally, we have the means of the two groups of samples (average weight of women = 73.21, average weight of men =51.25). In the result above : t is the Student t-test statistics value (t = 3.17), df is the degrees of freedom (df= 17.916), p-value is the significance level of the t-test (p-value = 0.0053). In this case, unpaired t-test can be calculated using the following R code : #res<-t.test(d$weight ~ d$group)Īs you can see, the two methods give the same results. T = -3.17, df = 17.92, p-value = 0.005319Īlternative hypothesis: true difference in means is not equal to 0Ģ) Method 2 - The data are saved in a ame : d<(list( In this case unpaired t-test can be performed as follow : res<-t.test(x,y) ![]() 1) Method 1 - The data are saved in two differents numeric vectors (x and y) : set.seed(1234)
0 Comments
Leave a Reply. |