Use of Anovan parameter 'continuous'?

15 views (last 30 days)
Jerry Gregoire
Jerry Gregoire on 18 Jul 2012
Edited: Adam Danz on 19 May 2020
The documentation for the parameter 'continuous' for anovan is scant. I have three factors, two are numeric: 'P','F', and one is categorical: 'W'. I assume that if I run an anova I should specify the numeric values. I see that if I don't I get radically different answers. Here is how I am calling it. Is it correct? I nominalized the categorical factor.
anovan(ds.R, [ds.Power ds.Freq double(nominal(ds.Waveform))], 'varnames', {'P' 'F' 'W'}, 'continuous', [1 2]);
Also, why is it so different? Anova w/o continuous (only main effects shown for brevity)
Source Sum Sq. d.f. Mean Sq. F Prob>F
----------------------------------------------------
P 5.463 1 5.4626 2.72 0.1027
F 7.114 1 7.1141 3.54 0.0631
W 0.312 1 0.3116 0.16 0.6946
Anova with continuous
P 22.821 1 22.8214 11.36 0.0011
F 10.206 1 10.2057 5.08 0.0267
W 5.732 1 5.7319 2.85 0.0947

Answers (2)

Matthew
Matthew on 18 Oct 2013
Jerry, you are right in that there is very little documentation of the ANOVAN function. I have similar questions around ANOVAN with continuous variables. In your specific case, getting different results might make sense depending on how the continuous data look.
Another related question:
Why does the ANOVA table produced by calling: anovan(y,{g_cat x},'model','full','continuous',[2])
differ from what is given by: aoctool(x,y,g_cat)
where x is a continuous variable (time, with three possible values 3, 6, 12 months) y is a measure of response g is a cell array full of either '1' or '2' for two different treatment groups.
I would have thought that these two models would be identical, but the results differ (calculated sum of squares are different, cannot be made to match when varying the sstype option). Better documentation of both functions would help a lot!

Adam Danz
Adam Danz on 23 Apr 2019
Edited: Adam Danz on 3 May 2020
"The documentation for the parameter 'continuous' for anovan is scant. I have three factors, two are numeric: 'P','F', and one is categorical: 'W'. I assume that if I run an anova I should specify the numeric values."
What matters is if they are continuous or categorical. For example, the first row below is continuous while the second row is categorical (although it's class is double). You should specify the continuous values.
F = [1.1 0.01 1.85 2.01 -0.12 -0.04];
W = [0 0 0 1 1 1 ];
% or categorical([0 0 0 1 1 1 ]);
"Why are my results different when I use a continuous variable?" [rephrased]
The anovan() function performs an n-way analysis of variance. When at least one of the grouping variables are labeled as continuous, the anovan() function peforms an ANCOVA instead (Matlab refers to it as an ANOCOVA, same thing). The ANCOVA considers covariance and an ANOVA does not.
This example here in the documentation demonstrates how anovan() is used to perform and ANCOVA.
  1 Comment
John TS
John TS on 3 May 2020
Also had a similar problem---- Matlab and SPSS agree in results when you use fixed FACTORS. As soon as you change 1 factor in Matlab to be 'Continuous'...the results are different! with MAtlab saying 1 degree of freedom for a factor that has 3 levels e.g. 5, 10 and 15 ...Someone to explain?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!