Get startedGet started for free

Perform a dependent t-test

Conducting a dependent t-test, also known as a paired t-test, requires the following steps:

  1. Define null and alternative hypotheses
  2. Decide significance level \(\alpha\)
  3. Compute observed t-value
  4. Find critical value
  5. Compare observed value to critical value

We're performing a Null Hypothesis Significance Test (NHST), so our null hypothesis is that there's no effect (i.e. training has no impact on intelligence scores). The alternative hypothesis is that training results in signficantly different intelligence scores. We'll use a significance level of 0.05, which is very common in statistics. That takes care of the first two steps!

In this exercise, we'll focus on computing the observed t-value, which is computed as follows:

$$ t = \frac{\bar{x}_D}{s_D / \sqrt{n}} $$

\(n\) is just the sample size, or the number of individuals in our sample. \(\bar{x}_D\) is the mean of the difference scores, or sum of the difference scores divided by the sample size. Finally, \(s_D\) is the standard deviation of the difference scores:

$$s_D = \sqrt\frac{\sum{(x_D - \bar{x}_D)^2}}{n-1}$$

In the formula for \(s_D\), \(x_D\) are the individual difference scores and should not be confused with \(\bar{x}_D\), which is the mean of the difference scores.

This exercise is part of the course

Intro to Statistics with R: Student's T-test

View Course

Exercise instructions

  • Use the code provided to assign the sample size to n.
  • Calculate the mean of the difference scores by summing up the differences with sum() and dividing by n. The differences are contained in the gain column of wm_t.
  • Compute the standard deviation of the difference scores as defined above. Use n and mean_diff in your calculation and be careful with your brackets! Save the result to sd_diff.
  • Compute the observed t-value by combining mean_diff, sd_diff, and n. Store the result in t_obs.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

## The training subset, wm_t, is available in your workspace

# Define the sample size
n <- nrow(wm_t)

# Mean of the difference scores
mean_diff <- ___

# Standard deviation of the difference scores
sd_diff <- sqrt(sum((___ - ___)^2) / (___))

# Observed t-value
t_obs <- ___ / (___ / sqrt(___))

# Print observed t-value
Edit and Run Code