Problem using ranova for analysis of variance

I'm trying to use ranova to analyse data from a fairly simple experiment, but am not successful as yet. The data (60x3) are attached. There were 60 teenage participants. The 1st column contains the measures on the dependent variable, grip strength. The 2nd and 3rd columns contain grouping codes for two independent variables, gender (m, f) and dietary group (dg1, dg2, dg3). So, there were 2x3=6 groups with 10 participants per group.
ranova seems to be the most flexible and powerful of MATLAB's anova functions, and I've had success with it in the past. But I'm coming up empty so far with this design. Here's the code I'm using:
T = readtable('testdata.txt');
T.Properties.VariableNames = {'DV', 'Gender', 'DietaryGroup' };
rm = fitrm(T,'DV ~ Gender-DietaryGroup','WithinDesign',table(1,'VariableNames',{'GripStrength'}));
AT = ranova(rm, 'WithinModel', 'GripStrength')
The output table includes an effect for gender but not for dietary group. As usual for a design like this, I need a main effect for each independent variable and also the interaction effect.
AT =
6×8 table
SumSq DF MeanSq F pValue pValueGG pValueHF pValueLB
________________ __ ________________ ________________ ____________________ ____________________ ____________________ ____________________
(Intercept) 132155.818801667 1 132155.818801667 1710.03811173231 9.71642961217613e-45 9.71642961217613e-45 9.71642961217613e-45 9.71642961217613e-45
Gender 783.442935000001 1 783.442935000001 10.1374066565166 0.00233737408952656 0.00233737408952656 0.00233737408952656 0.00233737408952656
Error 4482.37816333333 58 77.2823821264368
(Intercept):GripStrength 132155.818801667 1 132155.818801667 1710.03811173231 9.71642961217613e-45 9.71642961217613e-45 9.71642961217613e-45 9.71642961217613e-45
Gender:GripStrength 783.442935000001 1 783.442935000001 10.1374066565166 0.00233737408952656 0.00233737408952656 0.00233737408952656 0.00233737408952656
Error(GripStrength) 4482.37816333333 58 77.2823821264368
Any help you can offer is greatly appreciated.

 Accepted Answer

Scott, haven't you explicitly not included DietaryGroup with that minus sign? I think you are using it for predictors in a way that's only valid in the response specification.

3 Comments

Hey @Peter Perkins thanks a zillion. I changed the minus sign to an asterisk and now I'm getting the three important effects for this 2x3 between-subjects design: the main effect for Gender, the main effect for DietaryGroup, and the Gender x DietaryGroup interaction effect.
One very annoying issue remains. The anova table generated by ranova includes a lot of superfluous output. Here's the table:
AT =
10×8 table
SumSq DF MeanSq F pValue pValueGG pValueHF pValueLB
__________ __ __________ _______ __________ __________ __________ __________
(Intercept) 1.3216e+05 1 1.3216e+05 1965.9 3.7148e-44 3.7148e-44 3.7148e-44 3.7148e-44
Gender 783.44 1 783.44 11.654 0.0012218 0.0012218 0.0012218 0.0012218
DietaryGroup 824.45 2 412.22 6.1322 0.0039817 0.0039817 0.0039817 0.0039817
Gender:DietaryGroup 27.891 2 13.946 0.20745 0.8133 0.8133 0.8133 0.8133
Error 3630 54 67.223
(Intercept):GripStrength 1.3216e+05 1 1.3216e+05 1965.9 3.7148e-44 3.7148e-44 3.7148e-44 3.7148e-44
Gender:GripStrength 783.44 1 783.44 11.654 0.0012218 0.0012218 0.0012218 0.0012218
DietaryGroup:GripStrength 824.45 2 412.22 6.1322 0.0039817 0.0039817 0.0039817 0.0039817
Gender:DietaryGroup:GripStrength 27.891 2 13.946 0.20745 0.8133 0.8133 0.8133 0.8133
Error(GripStrength) 3630 54 67.223
The bottom five lines are just garbage, in my view. Am I over-specifying the design in some way? I've tried a few edits to simplify the design, but I keep getting compile errors. Can you spot a way to simplify the design to get rid of these lines?
I'm afraid ranova goes beyond my knowledge. I assume by "garbage" you mean "unrealistic estimates", and not "those lines should not be there".
OK, thanks for your follow-up on this point. I suppose "garbage" is a bit strong, but when I look at the tables generated by ranova, my response is... Ugh! What's going on here? There seems to be a mind-set issue here. I'm in that group of researchers that use the ananysis of variance to test for main effects and interaction effects in data collected in experimental research. We think about independent variables, dependent variables, and such. We're not thinking about building or testing prediction models with data collected in observational research or correlation research. The latter seems to be the mind set that comes with ranova.
For the design in my question, there are two between-subjects factors or independent variables. The anova table should provide the main effects and interaction effect for these two variables, and nothing more. To illustrate, here's the anova table for this same data set generated by JMP (from SAS Institute):
There is nothing unusual about the anova table above. It's what you get with pretty well any stats package and what you'll see in textbooks on statistical methods, research methods, etc.
The data in the table above are found in lines 2-5 in the table generated by ranova. The six additional lines in the table generated by ranova are just a nuisance in my view. I'd like to eliminate them, if possible. That's the essence of my follow-up question. Anyway, thanks again for your consideration on this issue and, in particular, for your answer to my question.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!