


Note that, by default, the t_test() function does not assume equal variances instead of the standard Student’s t-test, it uses the Welch t-test by default, which is the considered the safer one. Homogeneity of variances can be checked using the Levene’s test. However, to be consistent, the Shapiro-Wilk test can be used to ascertain whether data show or not a serious deviation from normality (See Chapter equality of variances. This implies that we can ignore the distribution of the data and use parametric tests. With large enough samples size (n > 30) the violation of the normality assumption should not cause major problems (according to the central limit theorem). the difference of pairs should follow a normal distribution.Īssessing normality.No significant outliers in the differences between groups.This assumption is made only by the original Student’s t-test. the variances of the two groups should not be significantly different.the two groups of samples (A and B), being compared, should be normally distributed.the data should be normally distributed.The t-test assumptions can be summarized as follow: We also explain the assumptions made by the t-test and provide practical examples of R codes to check whether the test assumptions are met. Note that, to compute one-sided t-tests, you can specify the option alternative, which possible values can be “greater”, “less” or “two.sided”. Mice2.long %>% t_test(weight ~ group, paired = TRUE) Quick start R codes, to compute the different t-tests, are: # One-sample t-test
Standard deviation in rstudio how to#
This chapter describes how to compare two means in R using t-test. Labs(subtitle = get_test_label(stat.test, detailed = TRUE)) Geom_vline(xintercept = 25, color = "blue", linetype = "dashed") + Stat_central_tendency(type = "mean", color = "red", linetype = "dashed") + Ggdensity(mice, x = "weight", rug = TRUE, fill = "lightgray") + Blue line corresponds to the theoretical mean.Red line corresponds to the observed mean.Subtitle = get_test_label(stat.test, detailed = TRUE) The measured mice mean weight (20.14 +/- 1.94) was statistically significantly lower than the population normal mean weight 25 ( t(9) = -8.1, p < 0.0001, d = 2.56) where t(9) is shorthand notation for a t-statistic that has 9 degrees of freedom.Ĭreate a box plot with p-value: bxp + labs( The mice weight value were normally distributed, as assessed by Shapiro-Wilk’s test (p > 0.05) and there were no extreme outliers in the data, as assessed by boxplot method. A one-sample t-test was computed to determine whether the recruited mice average weight was different to the population normal mean weight (25g).
