Exercise on the t-test (intermediate)

Scenario:
You are investigating whether a motivation workshop significantly increases employees’ motivation. To do this, motivation is measured before and after the workshop.

Dataset: Mittel_Motivationsvergleich.csv


Variables:

  • person: Participant ID
  • motivation_vorher: Scale score (1–10) before the workshop
  • motivation_nachher: Scale score (1–10) after the workshop

Solution in R

1. Import the data

daten <- read.csv("Mittel_Motivationsvergleich.csv")

2. Check the assumptions

a) Calculate and test the differences

daten$diff <- daten$motivation_nachher - daten$motivation_vorher
shapiro.test(daten$diff)

b) Visualize (optional)

boxplot(daten$motivation_vorher, daten$motivation_nachher, names = c("Before", "After"))
qqnorm(daten$diff); qqline(daten$diff)

3. Paired-samples t-test

t.test(daten$motivation_vorher, daten$motivation_nachher, paired = TRUE)

4. Alternative if the normality assumption is violated

wilcox.test(daten$motivation_vorher, daten$motivation_nachher, paired = TRUE)

Solution in SPSS

1. Import the file

  • Open SPSS
  • File → Open → Mittel_Motivationsvergleich.csv

2. Check the prerequisites

  • Menu: Analyze → Descriptive Statistics → Explore
  • Target variable: diff (only after calculation)
  • Create the difference: Transform → Compute Variable → motivation_nachher - motivation_vorher

→ The Shapiro–Wilk test and histogram provide information about the distribution


3. Paired-samples t-test

  • Menu: Analyze → Compare Means → Paired-Samples T Test
  • Pairs: motivation_vorher and motivation_nachher
  • Click OK

4. Alternative for non-normal distributions

Test: Wilcoxon signed-rank test

Menu: Analyze → Nonparametric Tests → Two Related Samples

Test variables: motivation_vorher, motivation_nachher

Alles klar?

Ich hoffe, der Beitrag war für dich soweit verständlich. Wenn du weitere Fragen hast, nutze bitte hier die Möglichkeit, eine Frage an mich zu stellen!

Stelle Dominik eine Frage