Perform repeated ANOVA on one group
43 views (last 30 days)
Show older comments
Hello,
Can we use Repeated measure ANOVA for a single group of few subjects having measurement at 3 different time points?It seems that this is an indication of this type of test and i found examples in python but with Matlab ranova if the predictors are all different it returns Nan? Should I just use anova1 to compare 3 points?
1 Comment
Scott MacKenzie
on 25 Oct 2023
Yes, you can use ranova. Post your data and I (or someone) will demo how.
Answers (1)
Shivansh
on 3 Jan 2024
Hi Elevada,
I understand that you are trying to use repeated measure ANOVA for a single group of a few subjects having measurement at three different time points.
In MATLAB, we can use “fitrm” to fit the repeated model first and then use the “ranova” function to perform the ANOVA.
Please refer to the below example code for a detailed idea of the above approach.
% data for 10 subjects measured at 3 time points
data = array2table(rand(10, 3), 'VariableNames', {'Time1', 'Time2', 'Time3'});
% Create a within-subjects design table indicating the measurements are repeated
withinDesign = table([1 2 3]', 'VariableNames', {'TimePoints'});
% Fit the repeated measures model
rmModel = fitrm(data, 'Time1-Time3~1', 'WithinDesign', withinDesign);
% Perform the repeated measures ANOVA
rmANOVA = ranova(rmModel);
% Display the results
disp(rmANOVA);
If you are still getting the output as “NaN”, you can check the structure of the data. The presence of a constant column in the dataset can also lead to “NaN” as a result.
The function "anova1" can be used to compare the three time points, but it does not take into account the repeated measures nature of the data. It can eventually fail to provide correct results in this case.
Refer to the following links for more information about "fitrm" and "ranova":
If you are still facing the same issue, kindly share more details regarding the data and the code file.
Hope it helps!
0 Comments
See Also
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!