Perform repeated ANOVA on one group

43 次查看(过去 30 天)
elevada
elevada 2023-10-25
回答: Shivansh 2024-1-3
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 个)

Shivansh
Shivansh 2024-1-3
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!

类别

Help CenterFile Exchange 中查找有关 Repeated Measures and MANOVA 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by