anovan returns NaN p-values

59 Ansichten (letzte 30 Tage)
laurie
laurie am 11 Sep. 2013
Beantwortet: es am 14 Mär. 2015
hello,
i have this mixed-model ANOVAn set up with 5 factors, including one random factor (subjects) nested in the between-subject factor "age". here is how i specify the model and such :
modeltype=[1 0 0 0 0 ; 0 1 0 0 0 ; 0 0 1 0 0 ; 0 0 0 1 0 ; 0 0 0 0 1 ; ... % Mains + Subject
1 1 0 0 0 ; 1 0 1 0 0 ; 1 0 0 1 0 ; ... % Age x Main
0 1 1 0 0 ; 0 1 0 1 0 ; 0 0 1 1 0 ; ... % Two-ways
1 1 1 0 0 ; 1 1 0 1 0 ; 1 0 1 1 0 ; ... % Age x Two-ways
0 1 1 1 0 ; ... % Three-way
1 1 1 1 0]; % Age x Three-way
M=zeros(5);% M(i,j) is 1 if variable i is nested in variable j ;
M(5,1)=1;% The Subjects factor is nested within the between‑subjects factor
[P,T,STATS]=anovan(log(RTs),{Age, Race , Sex , Emotion, Subjects}, 'random', 5, 'nested', M, 'model', modeltype ,'varnames',{'Age', 'Race' , 'Sex' , 'Emotion', 'Subjects'});
here is the ANOVA table i get :
Source Sum Sq. d.f. Mean Sq. F Prob>F
-------------------------------------------------------------------
Age 91.28 3 30.4278 8.19 NaN
Race 4.16 1 4.1592 1.1 NaN
Sex 2.21 1 2.2125 0.72 NaN
Emotion 1.53 2 0.7631 1.2 NaN
Subjects(Age) 272.04 59 4.6108 37.13 0
Age*Race 1.4 3 0.4658 2.58 NaN
Age*Sex 3.81 3 1.2702 7.15 NaN
Age*Emotion 1.22 6 0.204 1.62 NaN
Race*Sex 0.32 1 0.3223 0.66 NaN
Race*Emotion 0.45 2 0.2251 1.49 NaN
Sex*Emotion 4.78 2 2.3882 14.04 NaN
Age*Race*Sex 1.07 3 0.3583 1.51 NaN
Age*Race*Emotion 1.9 6 0.3174 2.56 NaN
Age*Sex*Emotion 1.95 6 0.3258 2.18 NaN
Race*Sex*Emotion 0.88 2 0.4406 3.19 NaN
Age*Race*Sex*Emotion 0.97 6 0.1612 1.02 NaN
Error 703.32 5663 0.1242
Total 1103.64 5769
The number of degrees of freedom isn't seem the problem here, right ? It says on Mathworks that the Mean Square of the Error shouldn't be close to zero, is it the problem and but how do i fix this ? Did i make a coding mistake ? What is wrong ?
Thank you very much for your help !
  2 Kommentare
laurie
laurie am 12 Sep. 2013
nobody knows what is going on ? the "Why do I recieve NaN's in the ANOVA table when I try to analyze my data using the Statistics Toolbox? " page on mathworks only talks about degrees of freedom left for the error (not the problem here ?) and means quare of the error close to zero (okay, might be the problem here, but i have seen anovan return valid p-values with smaller mean square errors than that..)... and most importantly... how do i fix this ?
laurie
laurie am 12 Sep. 2013
also when i don't specify that "Subjects" is random, i get numeric p-values... ???????

Melden Sie sich an, um zu kommentieren.

Antworten (1)

es
es am 14 Mär. 2015
I know that it might be a bit too late, but what I've figured out the following when I faced this problem:
a) In order to not get NaN for anovan one need to have at least two replications (measurements) for the same set of factor levels
b) In order to supply several replications for the same set of factor levels one need to just repeat set of factors in groups section.
For example: I studied 4-way anova. All possible combinations of my factors are: g1 = {'close'; 'close'; 'close'; 'close'; 'close'; 'close'; 'close'; 'close'; 'far'; 'far'; 'far'; 'far'; 'far'; 'far'; 'far'; 'far'};
g2 = {'young'; 'young'; 'young'; 'young'; 'mature'; 'mature'; 'mature'; 'mature'; 'young'; 'young'; 'young'; 'young'; 'mature'; 'mature'; 'mature'; 'mature'};
g3 = {'porlow'; 'porlow'; 'porhigh'; 'porhigh'; 'porlow'; 'porlow'; 'porhigh'; 'porhigh'; 'porlow'; 'porlow'; 'porhigh'; 'porhigh'; 'porlow'; 'porlow'; 'porhigh'; 'porhigh'};
g4 = {'perlow'; 'perhigh'; 'perlow'; 'perhigh'; 'perlow'; 'perhigh'; 'perlow'; 'perhigh'; 'perlow'; 'perhigh'; 'perlow'; 'perhigh'; 'perlow'; 'perhigh'; 'perlow'; 'perhigh'};
For each set of factors I have 4 measurements.
> anovan(y,{[g1; g1; g1; g1] [g2; g2; g2; g2] [g3; g3; g3; g3] [g4; g4; g4; g4]}, 'model', 'full');
gives the following results (y is a 64x1 column):
Source Sum Sq. d.f. Mean Sq. F Prob>F
---------------------------------------------------------
X1 2.3486 1 2.34856 3.71 0.0602
X2 1.8632 1 1.86322 2.94 0.0929
X3 0.1008 1 0.10081 0.16 0.6918
X4 5.267 1 5.26703 8.31 0.0059
X1*X2 0.0342 1 0.03422 0.05 0.8172
X1*X3 0.0046 1 0.00456 0.01 0.9328
X1*X4 0.64 1 0.64 1.01 0.32
X2*X3 0.5041 1 0.5041 0.8 0.3769
X2*X4 0.1871 1 0.18706 0.3 0.5894
X3*X4 0.0784 1 0.0784 0.12 0.7266
X1*X2*X3 0.8464 1 0.8464 1.34 0.2535
X1*X2*X4 0.1743 1 0.17431 0.28 0.6024
X1*X3*X4 0.009 1 0.00902 0.01 0.9055
X2*X3*X4 0.5814 1 0.58141 0.92 0.3429
X1*X2*X3*X4 0.2889 1 0.28891 0.46 0.5028
Error 30.4183 48 0.63371
Total 43.3463 63
If I use only one measurement for each set of factors level:
> anovan(yy, {g1 g2 g3 g4}, 'model', 'full');
gives the following results (yy is a 16x1 column):
Source Sum Sq. d.f. Mean Sq. F Prob>F
-----------------------------------------------------------
X1 0.58714 1 0.58714 Inf NaN
X2 0.46581 1 0.46581 Inf NaN
X3 0.0252 1 0.0252 Inf NaN
X4 1.31676 1 1.31676 Inf NaN
X1*X2 0.00856 1 0.00856 Inf NaN
X1*X3 0.00114 1 0.00114 Inf NaN
X1*X4 0.16 1 0.16 Inf NaN
X2*X3 0.12602 1 0.12602 Inf NaN
X2*X4 0.04676 1 0.04676 Inf NaN
X3*X4 0.0196 1 0.0196 Inf NaN
X1*X2*X3 0.2116 1 0.2116 Inf NaN
X1*X2*X4 0.04358 1 0.04358 Inf NaN
X1*X3*X4 0.00226 1 0.00226 Inf NaN
X2*X3*X4 0.14535 1 0.14535 Inf NaN
X1*X2*X3*X4 0.07223 1 0.07223 Inf NaN
Error -0 0 -0
Total 3.232 15
Best regards,
Evgeny

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by