Error when running a repeated measures ANOVA
2 ビュー (過去 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!