How to create a suitable statistical test for my repeated measures problem with unequal sample sizes?
Show older comments
dear community,
i have the following problem: I want to test differences of specific repeated measures during a pre and a post test:
my datasets has 10 subjects, each subjects did 2 tasks (called pre and post). during each task, I did repeated measurements of 5 different parameters (each set of 5 parameters were taken at the same time) over time. In addition, each pre and post measurement can be divided into two segments A and B. Now, i want to analyze the differences between pre and post on four different levels: on each of the parameters
taking parameter, I want to compare
- subject wise and segement wise, e.g. Subj1, pre, A to Subj1, post, A
- subjects wise only, both segments together, e.g. Subj1, pre, A+B to Subj1, post, A+B
- segment-wise, but all subjects, e.g. Subj1to10, pre, A to Subj1to10, post, B
- all subjects, both segements: Subj1to10, pre, A+B to Subj1to10, post, A+B
note that segments A/B and pre and post measurements do not have equal sample size, the samples are not independent and they may not be normally distributed.
How to tell, if there is a statistical significant difference between pre and post test at each of the four levels, and a suitable post-hoc analysis to tell, how this difference might be directed (probably looking at the median?)
And of course i need to compensate for mutiple comparison due to the 4 levels and the 5 parameters is measured at the same time?
best regards
Jonas
Answers (1)
Jaynik
on 17 Jun 2024
Hi Jonas,
To analyze the difference between pre and post tests in MATLAB on the four different levels described, you can use the ranova function to calculate repeated measures analysis of variance along with post-hoc tests to account for multiple comparisons. Following steps can be taken:
- Use the fitrm function to create repeated measures model from the dataset. Specify the WithinDesign parameter in fitrm. Apply ranova.
- After finding the significant effects with ranova, use multcompare for the post-hoc analysis to determine where the difference lies. Pairwise comparisons can be performed between different levels of the within-subject factor like pre and post for each subject or segment. Use the parameters like bonferroniin, tukey-kramer, dunn-sidak for protection in pairwise comparisons and adjust the significance level parameter alpha to account for the risk of Type 1 errors due to multiple comparisons.
- As the data might be not be normally distributed, you can apply mathematical transformations like log, sqrt, inverse transform (1 ./ data) etc. You can also consider using non-parametric tests like signrank (Wilcoxon Signed Rank Test), ranksum (Wilcoxon Rank Sum Test), kruskalwallis (Kruskal-Wallis Test), etc. Basically, it needs to be ensured that the model accounts for the repeated measures design properly.
Here’s a simplified example of how you might set up your analysis in MATLAB:
% Assuming 'data' is a table with your measurements and factors
% 'Param1', 'Param2', ..., 'Param5' are your repeated measures
% Fit the repeated measures model
rm = fitrm(data, 'Param1-Param5 ~ Subject*Segment', 'WithinDesign', withinDesign);
ranovatbl = ranova(rm);
postHocResults = multcompare(rm, 'Timepoint', 'By', 'Subject');
% Apply multiple comparison correction if needed
c = multcompare(rm, 'CriticalValueType ', 'bonferroni'); % example using the Bonferroni method
Remember to tailor the model specification to your dataset’s structure and the specific hypotheses you are testing.
You can refer the following documentation to read more about each functions:
- fitrm: https://www.mathworks.com/help/releases/R2022a/stats/fitrm.html
- ranova: https://www.mathworks.com/help/releases/R2022a/stats/repeatedmeasuresmodel.ranova.html
- multcompare: https://www.mathworks.com/help/releases/R2022a/stats/multcompare.html
- signrank: https://www.mathworks.com/help/releases/R2022a/stats/signrank.html
- ranksum: https://www.mathworks.com/help/releases/R2022a/stats/ranksum.html
- kruskalwallis: https://www.mathworks.com/help/releases/R2022a/stats/kruskalwallis.html
I hope this helps!
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!