MATLAB: N-way ANOVA giving NaN and Inf

n-way anova anova

Hello,
I tried to performe a n-way anova with the dataset in attachement. Also in attachement you can find Data_Read_2003_2010.m to import the dataset into matlab.
If I use only two terms and one factor I can get p-values for each of the terms tested.
68952280_2359880884108878_7933314197876637696_n.png
Once I try to use three or more terms, I get the values from the print screen bellow.
67963097_2373457922723356_156029646398291968_n.png
The command I am executing is the following: [p,tbl2,stats]=anovan(BPI_r,{GerBill' Yield_Spread_DE' PT_DE_Spread'})
Anyone know why I am getting Inf and NaN for F and p-values when I am using three or more terms in n-way anova? I also trying with different terms in the dataset and the entire dataset.
Best regards,
Bruno

Best Answer

According to the documentation, "By default, anovan treats all grouping variables as fixed effects." Your grouping variables do not seem to fit that description. They are continuous variables rather than factors.
% If your variables were factors, these plots would produce staircases
clf()
subplot(3,1,1)
plot(sort(GerBill))
subplot(3,1,2)
plot(sort(Yield_Spread_DE))
subplot(3,1,3)
plot(sort(PT_DE_Spread))
You'll need to indicate that they are continuous predictors by using the continuous property.
[p,tbl2,stats]=anovan(BPI_r,{GerBill' Yield_Spread_DE' PT_DE_Spread'},'continuous',1:3)
Result
You were getting NaNs because you need to have at least two replications for the same set of factor levels and since your "factors" were in reality continuous variables, there were not any repeated levels.