Two-way repeated measures fitrm error

2 views (last 30 days)
Zhané Murrell-Smith on 26 Feb 2020
Answered: Jeff Miller on 26 Feb 2020
I'm currently trying to perform a two-way RM ANOVA using the fitrm and ranova functions. I have followed the documentation for fitrm to the t but keep getting an error when I go to run my function. The code is designed to produce an anova for test-retest reliability for a large group of participants; I made up some mock participants and data to test the function and the code looks like this:
M = [99, 100; 87, 83; 95, 87; 62, 63; 100, 100; 90, 89; 72, 80; 88 90; 66 66; 78 82; 90 91; 83 85; 100 99; 99 98; 87 82; 77 78; 84 86; 92 92; 100 101; 87 92];
Test_1 = M(:,1);
Test_2 = M(:,2);
Subjects = ["P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11", "P12", "P13", "P14", "P15", "P16", "P17", "P18", "P19", "P20"]';
varNames = {'Subjects', 'Test_1', 'Test_2'};
Tbl = table(Subjects, Test_1, Test_2, 'VariableNames', varNames);
Tests = table(varNames(1,2:3)', 'VariableNames', {'Tests'});
rm = fitrm(Tbl, 'Test_1, Test_2~Subjects', 'WithinDesign', Tests);
Any help as to why it won't run, or better ways to perform a two-way repeated measures in MATLAB would be greatly appreciated!

Jeff Miller on 26 Feb 2020
You seem to have only two scores for each participant, M(:,1) and M(:,2), in which case you can find out whether the test means differ between Test_1 and Test_2 more simply with a ttest:
[a,b,c,d] = ttest(M(:,1)-M(:,2))
Just a comment, though, that this is not how people usually check reliability. This t-test, like the ANOVA you are contemplating, just checks whether there is an on-average change in the scores. Reliability is usually checked by seeing whether the Test_1 and Test_2 scores are well correlated across individuals (i.e., do people who score high on Test_1 also score high on Test_2?). For that, you might look at this correlation (or maybe Spearman if the data are not normally distributed):
r = corr(M(:,1),M(:,2))