Learn to compute participant-level difference scores, run paired t-tests, and interpret within-subject height changes using ABCD repeated measurements.
Work in ProgressExamples are a work in progress. Please exercise caution when using code examples, as they may not be fully verified. If you spot gaps, errors, or have suggestions, we'd love your feedback—use the "Suggest changes" button to help us improve!
Overview
Difference scores quantify change over time by subtracting initial measurements from follow-up measurements, isolating individual-level change within each participant. A paired samples t-test then evaluates whether the average change differs significantly from zero by comparing related measurements within the same group, accounting for each participant serving as their own control. This tutorial analyzes height measurements from ABCD youth across two annual assessments, computing difference scores to assess within-subject changes and applying a paired t-test to determine whether observed height changes are statistically significant.
When to Use:
Apply when you have two repeated measurements on each participant and want to test whether the average change differs from zero.
Key Advantage:
Paired t-tests work directly on within-subject differences, providing a simple, robust test that accounts for each child serving as their own control.
What You'll Learn:
How to compute difference scores, run a paired t-test in R, interpret the mean change and confidence interval, and visualize change via scatterplots.
Data Access
Data Download
ABCD data can be accessed through the DEAP platform or the NBDC Data Access Platform (LASSO), which provide user-friendly interfaces for creating custom datasets with point-and-click variable selection. For detailed instructions on accessing and downloading ABCD data, see the DEAP documentation.
Loading Data with NBDCtools
Once you have downloaded ABCD data files, the NBDCtools package provides efficient tools for loading and preparing your data for analysis. The package handles common data management tasks including:
Automatic data joining - Merges variables from multiple tables automatically
Built-in transformations - Converts categorical variables to factors, handles missing data codes, and adds variable labels
Event filtering - Easily selects specific assessment waves
The paired t-test indicates that the mean height difference of 2.33 inches is significantly greater than zero (p < .001), confirming reliable growth over the one-year period. The 95% confidence interval for the mean change (2.29 to 2.37 inches) stays well above zero, reinforcing that the effect is not driven by sampling noise. Cohen's d of 1.36 (95% CI: [1.33, 1.38]) reflects a large, practically meaningful shift in stature. Assumption checks (differences roughly symmetric, no extreme outliers) supported the validity of the paired-samples framework, so the reported effect can be interpreted with confidence.
Visualization
21 lines
# Select a random subset for visualization (e.g., 250 participants)
df_subset <- df_wide %>% sample_n(min(250, nrow(df_wide)))
# Create scatterplot using the subsample
visualization <- ggplot(df_subset, aes(x = Height_Baseline, y = Height_Year_1)) +
geom_point(aes(color = Height_Baseline), alpha = 0.6) + # Color points by baseline height
labs(
x = "Height at Baseline",
y = "Height at Year 1",
title = "Scatterplot of Heights at Baseline and Year 1",
subtitle = "Random subsample of 1000 participants"
) +
theme_minimal() +
geom_smooth(method = "lm", se = FALSE, color = "blue") + # Add a linear regression line
theme(legend.position = "bottom")
ggsave(
filename = "visualization.png",
plot = visualization,
width = 8, height = 6, dpi = 300
)
Interpretation
Visualization Notes
The scatterplot places Baseline height on the x-axis and Year 1 height on the y-axis, so points falling above the diagonal line represent participants who grew. Nearly all observations lie above the identity line and along the fitted regression line, emphasizing the uniformity of the height increase. Wider vertical spread at taller Baseline values hints at slightly greater variability among taller youth, yet the smooth line remains steep and linear, echoing the large effect detected in the t-test. The plot therefore offers a quick visual confirmation that growth occurred broadly rather than being driven by a small subset of participants.
Discussion
On average, participants exhibited a measurable increase in height across the two annual assessments, as indicated by positive difference scores. The paired samples t-test confirmed that the observed changes were statistically significant, suggesting that the increase in height is unlikely to be due to chance. The scatterplot of initial and follow-up measurements illustrates the general trend of growth, with most individuals showing an upward trajectory.
These findings demonstrate the utility of difference scores in capturing within-subject changes over time and highlight the effectiveness of paired samples t-tests for assessing statistically significant differences in repeated measures data. The method provides a straightforward approach to quantifying and testing within-subject change using two time points.
Additional Resources
4
R Documentation: t.test
DOCS
Official R documentation for the t.test() function, covering paired samples t-tests, confidence intervals, and assumptions for difference score analysis.
Comprehensive tutorial on conducting paired samples t-tests in R, including data preparation, assumption checking, effect size calculation, and result interpretation.
Methodology paper comparing difference score analysis with more sophisticated longitudinal methods, discussing when simple change scores are appropriate (Rogosa, 1988). Note: access may require institutional or paid subscription.