MATLAB: N-way ANOVA wrong results

anovaMATLABn-way anovaspssstatistics

Hi everyone,
I am doing some statistics functions in Matlab and checking them in SPSS. I am doing N-way ANOVA in Matlab, but it gives me wrong results comparing it to SPSS. As you can see later, the results completely differ, they are not even close. This is my code (I am showing you the brief version of the data to show what is going on):
connection= [0.3950; 0.3774; 0.0622; 0.0140; 0.1424; 0.1029; 0.1711; ...
0.1595; 0.0774; 0.0111];
abstinence=[12;6;8;11;14;6;3;6;3;4];
relapse=[0;1;2;0;1;1;3;0;1;0];
[~,tbl]=anovan(connection,{abstinence, relapse},'display','on','model','full',...
'varnames',{'Abstinence','Relapse'}, 'continuous',[1,2]);
I am doing it to be full interaction and with continuous predictors, the same as in SPSS. And this gives me this results in Matlab:
Source Sum Sq. d.f. Mean Sq. F Prob>F
----------------------------------------------------------------
Abstinence 0.02207 1 0.02207 0.93 0.3714
Relapse 0.01428 1 0.01428 0.6 0.4667
Abstinence*Relapse 0.01587 1 0.01587 0.67 0.4441
Error 0.14196 6 0.02366
Total 0.1653 9
And in SPSS (sorry it is in Spanish: Abstinencia is Abstinence and Recaidas is Relapse, just in case):
5.JPG
I don't know why this is happening or if I am doing something wrong. Besides, I have changed 'model' to 'interaction' and it does not work either. Please any help is welcomed!
Thanks in advanced.

Best Answer

Both of the MATLAB output tables make sense to me, but I don't really know what SPSS is doing.
For the MATLAB continuous case, the model says that connection changes linearly with Abstinence, with Relapse, and with Abstinence*Relapse. The 1 df for each of those terms is a slope relating connection to each of these three numerical predictors. (This is really a regression model.)
For the MATLAB non-continuous case, each different score on Abstinence and Relapse indicates a qualitatively different condition (i.e., imagine that the numbers were just arbitrary labels). Since you have 7 different Abstinence values, this model requires 6 df for Abstinence differences. Similarly you have a lot of distinct Relapse values & a whole lot of possible interaction terms. Basically, you have no where near enough data to estimate the parameters of this model, hence all those zeros in the table.
SPSS is claiming 5 dfs for Abstinence and 2 for Relapse, but I don't know why those aren't 6 & 3 (number of distinct scores minus 1). It has excluded the interaction term completely (0 df), presumably because it recognizes that there are not enough data to estimate those terms.
Bottom line: With your data, it does not seem feasible to use ANOVA as you are trying to do it. This analysis is meant to be used with categorical predictors (i.e., having a few distinct values, which are not assumed to be numerically meaningful), and with lots of data for all possible combinations of values on all the different predictors. For example, you would need several cases with Abstinence=4 & Relapse=0, several with Abstinence=4 & Relapse=1, and so on for all possible cases. I think regression modelling is more suitable for the type of data that you seem to have.
Related Question