Error when running a repeated measures ANOVA

17 visualizaciones (últimos 30 días)
pablo dopico
pablo dopico el 23 de Nov. de 2020
Comentada: pablo dopico el 24 de Nov. de 2020
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);

Respuesta aceptada

Jeff Miller
Jeff Miller el 23 de Nov. de 2020
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 comentarios
Jeff Miller
Jeff Miller el 24 de Nov. de 2020
Right. And you need to specify that the variables of WithinDesign are categorical. The example here may help.
pablo dopico
pablo dopico el 24 de Nov. de 2020
Thanks so much for your help, I'll give this a shot, i think I understand this much better now.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by