Exercise

# 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.

Instructions

**100 XP**

- 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`

.