I have repeated measures data (pre-test
This is a classic repeated measures design, and the best way to analyze it depends critically on one piece of information you haven't mentioned: do you have a control group?
Let's break down the approach based on whether you have an intervention group only or an intervention group plus a control group.
Crucial First Question: Do you have a Control Group?
- Yes (Intervention Group vs. Control Group): This is the ideal scenario for assessing the intervention's effectiveness and is what most of the following will assume. You can establish causality (or at least stronger evidence for it).
- No (Intervention Group Only): This is a pre-post design with follow-ups for a single group. While you can still analyze changes over time, you cannot definitively attribute those changes solely to your intervention, as other factors (maturation, historical events, regression to the mean) could be responsible.
Scenario 1: You have an Intervention Group AND a Control Group (Recommended Approach)
This is the most robust design. The goal is to see if the intervention group's change over time differs significantly from the control group's change over time.
Recommended Statistical Method: Linear Mixed Model (LMM) / Mixed-Effects Model
LMMs are highly flexible and robust for repeated measures data, especially when you have multiple time points and potentially missing data.
1. Data Preparation:
- Long Format: Your data should be in "long format." This means each row represents a single observation for a subject at a specific time point, rather than each row being a subject with multiple columns for time points.
- Columns you need:
Subject_ID
: Unique identifier for each participant.Time
: A numerical or ordered categorical variable (e.g., 0 for pre, 1 for post, 2 for follow-up 1, 3 for follow-up 2).Group
: A categorical variable (e.g., "Intervention", "Control").Outcome_Variable
: Your pre-test/post-test score.- Any other covariates you might want to include (age, gender, baseline characteristics).
2. Exploratory Data Analysis (EDA):
- Visualize: Create line plots showing the mean (or median) of your
Outcome_Variable
overTime
, separated byGroup
. This will give you a visual sense of whether the groups diverge after the intervention. - Summary Statistics: Calculate means, standard deviations, and ranges for each group at each time point.
- Check for Outliers: Box plots by group and time can help identify unusual data points.
3. Model Specification (Simplified Example):
The core idea is to model the OutcomeVariable
as a function of Time
, Group
, and their interaction, while accounting for the fact that observations from the same SubjectID
are related.
- Fixed Effects: These are the effects you are primarily interested in.
Time
: Does the outcome change over time in general?Group
: Is there an overall difference between the intervention and control groups, irrespective of time?Time Group
(Interaction Term): This is the most important term. It tells you if the change over time* in the outcome variable is different between the intervention and control groups. A significant interaction here means your intervention had a differential effect over time compared to the control group.- Random Effects: These account for individual variability.
(1 | SubjectID)
: This specifies a random intercept for each subject, meaning each subject has their own baseline level of the outcome. This is the most common and often sufficient random effect. You could also include(Time | SubjectID)
if you suspect individuals have different slopes (rates of change) over time, but start simpler.
Example LMM in R (using
lmer
from lme4
package):library(lme4)
model <- lmer(Outcome_Variable ~ Time * Group + (1 | Subject_ID), data = your_data_long)
summary(model)
4. Interpretation of Results:
- **Focus on the
Time * Group
Interaction:** - If it's significant (p < 0.05), it indicates that the effect of time on your outcome variable is different for the intervention group compared to the control group. This is what you're hoping for – evidence that your intervention worked.
- If it's not significant, it suggests that the change over time is similar for both groups, implying your intervention might not have had a unique effect.
- Main Effects (Time, Group): Interpret these carefully in the presence of a significant interaction. A significant main effect of
Time
means there's an overall change across time, and a significant main effect ofGroup
means there's an overall difference between groups, averaging across all time points. However, the interaction term usually supersedes these if it's significant. - Random Effects: The variance of the random intercept tells you how much variability there is between subjects in their baseline outcome scores.
**5. Post-Hoc Tests (if
Time * Group
interaction is significant):**If the interaction is significant, you'll want to pinpoint where the differences lie. Common post-hoc comparisons include:
- Between-Group Comparisons at Each Time Point:
- Is the intervention group different from the control group at post-test?
- Is the intervention group different from the control group at follow-up 1?
- Is the intervention group different from the control group at follow-up 2?
- (Often, you'd expect no difference at pre-test if randomization was successful).
- Within-Group Comparisons Over Time:
- For the intervention group: Is post-test different from pre-test? Is follow-up 1 different from post-test? Etc.
- For the control group: (Same comparisons, expecting no significant changes or a different pattern).
Important: Remember to adjust p-values for multiple comparisons (e.g., Bonferroni, Tukey, Holm, Sidak) to avoid increasing your Type I error rate.
Alternative: Repeated Measures ANOVA (RM-ANOVA)
- When to use: If your data meet strict assumptions (normality, sphericity, no missing data) and your design is perfectly balanced, RM-ANOVA can be used. It's conceptually simpler for some but less flexible than LMMs.
- How it works: It typically requires data in "wide format" (one row per subject, columns for pre, post, F1, F2). You would specify
Time
as a within-subjects factor andGroup
as a between-subjects factor. - Outputs: You'll get F-statistics for the main effects of Time, Group, and the critical
Time * Group
interaction. - Assumptions: RM-ANOVA is sensitive to violations of sphericity (tested by Mauchly's test). If violated, you need to apply corrections (Greenhouse-Geisser or Huynh-Feldt).
- Limitations: Handles missing data poorly (usually requires listwise deletion, which can reduce sample size and power).
Scenario 2: You have an Intervention Group ONLY (No Control Group)
In this case, you can't truly test the effect of your intervention in a causal sense, but you can describe changes within your group over time.
Recommended Statistical Method: Linear Mixed Model (LMM) or Repeated Measures ANOVA (RM-ANOVA)
The principles are similar to above, but the Group
factor is removed.
1. Data Preparation:
- Still use long format:
SubjectID
,Time
,OutcomeVariable
.
2. Model Specification:
- LMM:
OutcomeVariable ~ Time + (1 | SubjectID)
- You are looking for a significant main effect of
Time
. If it's significant, it means there's an overall change in your outcome variable across the different time points. - RM-ANOVA (One-Way):
Outcome_Variable
withTime
as the within-subjects factor.- Again, you're looking for a significant main effect of
Time
.
3. Interpretation and Post-Hoc Tests:
- If
Time
is significant, perform post-hoc tests to determine which time points are significantly different from each other (e.g., is post-test different from pre-test? Is follow-up 1 different from post-test? etc.). - Crucial Caveat: Remember to state the limitation that without a control group, you cannot definitively attribute these changes to your intervention. Other factors could be at play.
Important Considerations for Both Scenarios:
- Assumptions:
- Normality of Residuals: LMMs are quite robust to minor deviations from normality, especially with larger sample sizes. If severely non-normal, consider transformations or Generalized Linear Mixed Models (GLMMs) if your outcome is not continuous (e.g., binary, count data).
- Homoscedasticity: Variance of residuals should be constant.
- Sphericity (for RM-ANOVA): This assumption is about the equality of variances of the differences between all pairs of within-subject conditions. LMMs don't require this assumption due to their explicit modeling of within-subject correlation.
- Missing Data:
- LMMs are a major advantage here. They use all available data points (Full Information Maximum Likelihood - FIML) and are robust to data that are "Missing At Random" (MAR), meaning the missingness can be predicted from other observed variables in the model.
- RM-ANOVA typically performs "listwise deletion," meaning subjects with any missing data point across time are excluded entirely, which can drastically reduce your sample size and introduce bias.
- Covariates: You can easily add other variables (e.g., age, gender, baseline anxiety) to your LMM as fixed effects if you want to control for their influence or see if they moderate the intervention's effect.
- Software:
- R:
lme4
(for LMMs),nlme
,afex
(for RM-ANOVA and convenience functions),emmeans
(for post-hoc tests). - Python:
statsmodels
(for LMMs). - SPSS:
Analyze > General Linear Model > Repeated Measures
(for RM-ANOVA) orAnalyze > Mixed Models > Linear
(for LMMs). - SAS:
PROC MIXED
(for LMMs),PROC GLM
(for RM-ANOVA).
In summary, if you have a control group, a Linear Mixed Model is almost always the preferred and most powerful approach for analyzing your repeated measures data. It offers flexibility, handles missing data well, and directly tests your primary hypothesis of an interaction between time and group.
Great! Repeated measures data, such as pre-test and post-test scores, are commonly analyzed to assess changes over time or under different conditions. Here are some steps and methods you can use to analyze your repeated measures data:
1. Descriptive Statistics
- Mean and Standard Deviation: Calculate the mean and standard deviation for both pre-test and post-test scores.
- Median and Range: These can also be useful, especially if your data is not normally distributed.
2. Visualization
- Box Plots: Useful for visualizing the distribution and identifying outliers.
- Line Plots: Can show individual changes over time.
- Histograms: To visualize the distribution of scores.
3. Statistical Tests
- Paired t-test: If you have two time points (pre-test and post-test) and your data is normally distributed, a paired t-test can be used to compare the means.
- Wilcoxon Signed-Rank Test: If your data is not normally distributed, this non-parametric test can be used.
- Repeated Measures ANOVA: If you have more than two time points or conditions, a repeated measures ANOVA can be used to compare means across multiple groups.
- Mixed-Effects Models: If you have additional factors (e.g., different groups or treatments), a mixed-effects model can account for both fixed and random effects.
4. Effect Size
- Cohen's d: For paired t-tests, Cohen's d can be used to measure the effect size.
- Partial Eta Squared (η²): For ANOVA, partial eta squared can be used to measure the effect size.
5. Assumptions
- Normality: Check if your data is normally distributed using tests like the Shapiro-Wilk test or visual methods like Q-Q plots.
- Sphericity: For repeated measures ANOVA, check the assumption of sphericity using Mauchly's test. If sphericity is violated, you may need to apply a correction (e.g., Greenhouse-Geisser).
Example Analysis in R
Here's a simple example of how you might analyze pre-test and post-test scores using R:
# Load necessary libraries
library(dplyr)
library(ggplot2)# Example data
data <- data.frame(
id = 1:10,
pre_test = c(5, 6, 7, 8, 9, 5, 6, 7, 8, 9),
post_test = c(6, 7, 8, 9, 10, 6, 7, 8, 9, 10)
)
# Descriptive statistics
summary(data)
# Paired t-test
t.test(data$pre_test, data$post_test, paired = TRUE)
# Wilcoxon Signed-Rank Test
wilcox.test(data$pre_test, data$post_test, paired = TRUE)
# Visualization
ggplot(data, aes(x = factor(0), y = pre_test)) +
geom_boxplot() +
geom_point(aes(y = post_test), color = "red") +
labs(x = "Test", y = "Score") +
theme_minimal()
Example Analysis in Python
Here's a similar example using Python with the
pandas
and scipy
libraries:import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import ttest_rel, wilcoxon# Example data
data = pd.DataFrame({
'id': range(1, 11),
'pre_test': [5, 6, 7, 8, 9, 5, 6, 7, 8, 9],
'post_test': [6, 7, 8, 9, 10, 6, 7, 8, 9, 10]
})
# Descriptive statistics
print(data.describe())
# Paired t-test
t_stat, p_value = ttest_rel(data['pre_test'], data['post_test'])
print(f"Paired t-test: t-statistic = {t_stat}, p-value = {p_value}")
# Wilcoxon Signed-Rank Test
w_stat, p_value = wilcoxon(data['pre_test'], data['post_test'])
print(f"Wilcoxon Signed-Rank Test: w-statistic = {w_stat}, p-value = {p_value}")
# Visualization
sns.boxplot(data=data[['pre_test', 'post_test']])
plt.show()
Conclusion
Choosing the right method depends on the nature of your data and the specific questions you are trying to answer. Always check the assumptions of the tests you are using and consider the effect size to interpret the practical significance of your results.
💡 Try this comparison yourself:Compare AI models side-by-side on SNEOS
Analysis
This comparison demonstrates the different approaches each AI model takes when responding to the same prompt. Here are the key differences observed:
Response Characteristics
Gemini: Provides a direct response with 107 sentences.
Mistral: Provides a detailed response with 36 sentences.
Key Takeaways
- Each model brings unique strengths to this type of query
- Response styles vary significantly between models
- Consider your specific use case when choosing between these models
Try This Comparison Yourself
Want to test these models with your own prompts? Visit SNEOS.com to compare AI responses side-by-side in real-time.
This comparison was generated using the SNEOS AI Comparison ToolPublished: October 15, 2025 | Models: Gemini, Mistral