From: Renat on
I would like to do an ANCOVA analysis on my data.

I have a measure (thickness) and two groups (study, control). I want to see if there is a significant difference in the thickness between the two groups, co-varying for age. How do I do this in matlab?

I have already tried anova1, anova2, anovan, and aoctool, but none of them matched up with what our stats person got using SAS. This is the output from SAS:

Sum of
Source DF Squares Mean Square F Value Pr > F
Model 2 0.00139984 0.00069992 2.07 0.1970
Error 7 0.00236955 0.00033851
Corrected Total 9 0.00376939

R-Square Coeff Var Root MSE FA_ACR_L Mean
0.371370 4.531106 0.018399 0.406050

Source DF Type III SS Mean Square F Value Pr > F
status 1 0.00018384 0.00018384 0.54 0.4851
Scan_Age 1 0.00138330 0.00138330 4.09 0.0829

And this is my matlab code:
[ thickness age group]

ans =

0.4127 13.9000 2.0000
0.4340 14.7200 2.0000
0.3815 16.5500 2.0000
0.3868 19.0000 2.0000
0.4246 16.3400 2.0000
0.3904 15.2100 2.0000
0.3810 21.8900 1.0000
0.4049 17.3600 1.0000
0.4329 16.1000 1.0000
0.4117 13.5000 1.0000

>> [h,a,c,s]=aoctool(thickness,age,group,.05,'','','','off','separate lines')

h =

Empty matrix: 0-by-1


a =

'Source' 'd.f.' 'Sum Sq' 'Mean Sq' 'F' 'Prob>F'
'group' [ 1] [ 5.0141] [ 5.0141] [1.0762] [0.3395]
'thickness' [ 1] [19.5411] [19.5411] [4.1941] [0.0865]
'group*thickness' [ 1] [ 5.5024] [ 5.5024] [1.1810] [0.3189]
'Error' [ 6] [27.9551] [ 4.6592] [] []


c =

'Term' 'Estimate' 'Std. Err.' 'T' 'Prob>|T|'
'Intercept' [ 50.2990] [ 14.8934] [ 3.3773] [ 0.0149]
' 1' [ 16.8916] [ 14.8934] [ 1.1342] [ 0.3000]
' 2' [-16.8916] [ 14.8934] [-1.1342] [ 0.3000]
'Slope' [-82.8522] [ 36.5830] [-2.2648] [ 0.0641]
' 1' [-39.7558] [ 36.5830] [-1.0867] [ 0.3189]
' 2' [ 39.7558] [ 36.5830] [ 1.0867] [ 0.3189]


s =

source: 'aoctool'
gnames: {2x1 cell}
n: [2x1 double]
df: 6
s: 2.1585
model: 5
slopes: [2x1 double]
slopecov: [2x2 double]
intercepts: [2x1 double]
intercov: [2x2 double]
pmm: [2x1 double]
pmmcov: [2x2 double]


I have also tried it using all of the other 'separate means', 'parallel lines', etc models, but still can't get SAS's Source -> status -> Pr > F value (.4851) to match anything in matlab.

Can anyone point out what I'm doing wrong? Thank you!
From: Peter Perkins on
On 7/29/2010 5:33 PM, Renat wrote:
> I have also tried it using all of the other 'separate means', 'parallel
> lines', etc models, but still can't get SAS's Source -> status -> Pr > F
> value (.4851) to match anything in matlab.

Renat, when I do this:

X = [0.4127 13.9000 2.0000
0.4340 14.7200 2.0000
0.3815 16.5500 2.0000
0.3868 19.0000 2.0000
0.4246 16.3400 2.0000
0.3904 15.2100 2.0000
0.3810 21.8900 1.0000
0.4049 17.3600 1.0000
0.4329 16.1000 1.0000
0.4117 13.5000 1.0000];
Thickness = X(:,1); Age = X(:,2); Group = X(:,3);
[~,atab,ctab,stats] = aoctool(Age,Thickness,Group,0.05, ...
'Age','Thickness','Group','on','parallel lines');

I see .48517 (rounded to .4852 in the figure window) in the Prob>F for
Group. That's what you're looking for, right?