Perform a dependent t-test
Conducting a dependent t-test, also known as a paired t-test, requires the following steps:
- Define null and alternative hypotheses
- Decide significance level \(\alpha\)
- Compute observed t-value
- Find critical value
- 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
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 byn
. The differences are contained in thegain
column ofwm_t
. - Compute the standard deviation of the difference scores as defined above. Use
n
andmean_diff
in your calculation and be careful with your brackets! Save the result tosd_diff
. - Compute the observed t-value by combining
mean_diff
,sd_diff
, andn
. Store the result int_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