# T-Test Essentials: Definition, Formula and Calculation

## Course description

The t-test can be defined as a statistical test used to compare two means. This guide provide multiple tutorials describing the different types of t-test, including:

• one-sample t-tests. Compares one-sample mean to a know standard mean.
• independent samples t-tests: Student’s t-test and Welch’s t-test. Compares two independent groups
• paired samples t-test. Compares two related samples.

You will learn the t-test formula and how to:

• Compute the different t-tests in R
• Check t-test assumptions
• Calculate and report t-test effect size using Cohen’s d.

Contents:

#### Related Book

Practical Statistics in R II - Comparing Groups: Numerical Variables

## Prerequisites

Make sure you have installed the following R packages:

• tidyverse for data manipulation and visualization
• ggpubr for creating easily publication ready plots
• rstatix provides pipe-friendly R functions for easy statistical analyses.
• datarium: contains required data sets for this chapter.

library(tidyverse)
library(ggpubr)
library(rstatix)

## Examples of R codes

Comparing two independent groups:

# Data preparation
data("genderweight", package = "datarium")
head(genderweight, 3)
## # A tibble: 3 x 3
##   id    group weight
##   <fct> <fct>  <dbl>
## 1 1     F       61.6
## 2 2     F       64.6
## 3 3     F       66.2
# Statistical test
stat.test <- genderweight %>%
t_test(weight ~ group) %>%
stat.test
## # A tibble: 1 x 9
##   .y.    group1 group2    n1    n2 statistic    df        p p.signif
##   <chr>  <chr>  <chr>  <int> <int>     <dbl> <dbl>    <dbl> <chr>
## 1 weight F      M         20    20     -20.8  26.9 4.30e-18 ****
# Visualization:
# Create a box-plot
bxp <- ggboxplot(
genderweight, x = "group", y = "weight",
ylab = "Weight", xlab = "Groups", add = "jitter"
)
# Add p-value and significance levels
stat.test <- stat.test %>% add_xy_position(x = "group")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed = TRUE))

Version: Français

1. ## Types of T-Test

Describes the different types of t-test for comparing the means of groups. These include: one-sample t-tests, unpaired t-test and paired t-test.
1. ## One Sample T-Test

Describes the one-sample t-test, which is used to compare the mean of one sample to a known standard (or theoretical / hypothetical) mean. You will learn the formula, assumptions, calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting in R.
2. ## Unpaired T-Test

Describes the unpaired t-test, which is used to compare the mean of two independent groups. You will learn the formula, assumptions, calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting in R. The Student's t-test and the Welch t-test are described.
1. ## Student's T-Test

Describes the Student's t-test, which is used to compare the mean of two independent groups. You will learn the formula, assumptions, calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting in R.
2. ## Welch T-Test

Describes the Welch t-test, which is used to compare the mean of two independent groups. You will learn the formula, assumptions, calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting in R.
3. ## Paired T-Test

Describes the paired t-test, which is used to compare the mean of two related groups of samples. You will learn the formula, assumptions, calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting in R.
2. ## Pairwise T-Test

Describes how to compute the pairwise T-test in R between groups with corrections for multiple testing. The pairwise t-test consists of calculating multiple t-test between all possible combinations of groups. You will learn how to: 1) Calculate pairwise t-test for unpaired and paired groups; 2) Display the p-values on a boxplot.
3. ## T-Test Formula

Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.
1. ## One Sample T-Test Formula

Describes the one sample t-test formula, which is used to compare the mean of one sample to a known standard mean.
2. ## Independent T-Test Formula

Describes the independent t-test formula, which is used to compare the means of two independent groups. You will learn the Student t-test formula and the Weltch t-test formula.
3. ## Paired T-Test Formula

Describes the paired t-test formula, which is used to compare the means of two related groups or samples.
4. ## T-Test Assumptions

Describes the t-test assumptions and provides examples of R code to check whether the assumptions are met before calculating the t-test. You will learn the assumptions of the different types of t-test, including the one-sample t-test, independent t-test and paired t-test.
1. ## One Sample T-Test Assumptions

Describes the one sample t-test assumptions and provides examples of R code to check whether the assumptions are met before calculating the t-test.
2. ## Independent T-Test Assumptions

Describes the independent t-test assumptions and provides examples of R code to check whether the assumptions are met before calculating the t-test.
3. ## Paired T-Test Assumptions

Describes the paired t-test assumptions and provides examples of R code to check whether the assumptions are met before calculating the t-test.
5. ## How to Do a T-test in R: Calculation and Reporting

Describes how to do a t-test in R/Rstudio. You will learn how to 1) interpret and report the t-test; 2) add p-values and significance levels to a plot and 3) calculate and report the t-test effect size.
1. ## How To Do a One-Sample T-test in R

Describes how to do a one-sample t-test in R/Rstudio. You will learn the calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting.
2. ## How To Do Two-Sample T-test in R

Describes how to do a two-sample t-test in R/Rstudio. You will learn the calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting.
3. ## How to Do Paired T-test in R

Describes how to do a paired t-test in R/Rstudio. You will learn the calculation, visualization, effect size measure using the Cohen's d, interpretation and reporting.
6. ## T-test Effect Size using Cohen's d Measure

Describes the t-test effect size using the Cohen's d. You will learn Cohen's d formula, calculation in R, interpretation of small, medium and large effect.

Fantastic lesson! I’m currently bingeing all of Alboukadel Kassambara’s lessons on this website. Really clear and concise.

• Kassambara

Thank you for your positive feedback, highly apprecited

• Krzysztof Polowy

Hi, I have just completed this first course on your website. What a fantastic work – simple, concise and clear, but most of all – with a workable expamles! I enoyed it very much and I’m sure to use many of your other courses right away!
Thanks for all your good work!

• Kassambara

Thank you very much for the positive feed. I’m very happy that it was useful for you.

## 5

(1 votes, average: 5.00 out of 5)