Error when running a repeated measures ANOVA
10 次查看(过去 30 天)
显示 更早的评论
Hello, I need to run a repeated measure ANOVA with three independent factors, but I'm struggling to make my code work even with just one factor.
Below is my code.
words is a matrix with columns corresponding to patient IDs (integers 1-205). Vowel, Treatment, and Test are all factors, but are replaced with a number (ex. Test can take the value 1, 2, or 3). Test is the repeated measure "time" variable. MD is the dependent outcome variable.
I tried running my ANOVA without including other factors at first, following along with other examples, I've seen. I keep getting the error:
"Error using RepeatedMeasuresModel/set.WithinDesign (line 1235) Specified design has 3 points; 1 required. "
I guess I don't understand the role of WithinDesign very well. Could someone help me out a bit?
Thank you!
words = array2table(words);
stories = array2table(stories);
words.Properties.VariableNames(1:5) = {'ID','Vowel','Treatment','Test','MD'};
withinDsgn = table((1:3)','VariableNames',{'Test'});
wordsrm = fitrm(words, 'MD~ID*Test', 'WithinDesign', withinDsgn);
0 个评论
采纳的回答
Jeff Miller
2020-11-23
I'm pretty sure fitrm expects all of the data from a single patient to be on one row of the input data table (e.g., words)--at least by default, maybe there is some way around this. So, for your example with 3 tests, it would expect 3 separate columns of data, say Test1, Test2, Test3, and a command like
wordsrm = fitrm(words,'Test1-Test3 ~ ID','WithinDesign', withinDsgn)
Your fitrm command only specified one score (MD), so fitrm thought the WithinDesign 'required' only one condition per patient, and it was confused because your WithinDesign specifies 3 conditions.
Additional repeated measures factors would multiply the number of columns to the left of the '~' in the model statement.
3 个评论
Jeff Miller
2020-11-24
Right. And you need to specify that the variables of WithinDesign are categorical. The example here may help.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Repeated Measures and MANOVA 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!