ANCOVA A hybrid of regression and analysis of variance

advertisement
ANCOVA
A hybrid of regression and
analysis of variance
Analysis of covariance
• It is an analysis of variance performed on
residuals from the regression of the
response variable on the covariate
Analysis of covariance
Yij    Ai  i ( X ij  X i )   ij
Yij    Ai  C ( X ij  X i )   ij
Plotting ANCOVAs
• The ANCOVA plot should use the
continuous covariate variable plotted on
the x-axis, and the Y variable plotted on
the y-axis. Each point represents an
independent replicate, and different
symbols or colors should be used for each
treatment group.
Plotting results
A
D
B
E
C
F
Match???
1.
2.
3.
4.
5.
6.
Treatment significant, covariate and interaction term
non-significant (C)
Treatment and covariate significant, interaction term
non-significant (D)
Interaction term significant, everything else nonsignificant (E)
Covariate not significant, treatment, and interaction
significant (F)
Covariate significant, treatment and interaction nonsignificant (B)
No term significant (A)
Dangerous data!!
60
50
40
T1
T2
T3
30
20
10
0
0
2
4
6
8
10
12
An important thing…
• In Analysis of Covariance order matters
• This model:
model <- lm(Y ~ X*Group)
• is not the same as this one
model <- lm(Y ~ Group*X)
Membrane potential (in millivolts)
'Action potential' is the name
given to the electrical nerve
impulse waveform that is
generated by the neuron (nerve
cell). The shape of an action
potential can be seen using an
amplifier circuit (voltage clamp)
as shown in the diagram below,
which measures the flow of ions
using two electrodes inserted into
the nerve fibre.
www.ebme.co.uk/arts/aps/pic1a.gif
Membrane potential (in millivolts)
• Yamauchi and Kimizuka (1971) measured membrane
potential for 4 different cation systems as a function of
the logarithm of the activity ratio of various electrolytes
are various concentrations. We wish to test whether the
mean membrane potential “Y” is different for these
systems
Data
a= 4 groups (cation systems)
Ca-Li
Ca-K
Sr-Na
Y
X
Y
X
Y
X
Y
X
-2.4
-0.31
-7.0
-1.18
-10.8
-1.79
-5.4
-1.83
6.3
0.17
2.1
-0.65
-2.8
-1.21
3.0
-1.25
15.8
0.58
17.8
0.10
14.2
-0.35
20.7
-0.41
20.5
0.81
27.3
0.50
25.5
0.08
30.5
0.05
32.0
0.67
35.7
0.49
39.9
0.43
41.2
0.65
45.0
0.59
N
X
Ca-Na
4
10.05
5
0.312
6
6
14.44 -0.112 17.17 -0.355 22.28 -0.403
Membrane potential for four
different cation systems
mean membrane potential (in mV)
60
Ca-Li
Ca-Na
Ca-K
Sr-Na
Linear (Sr-Na)
Linear (Ca-Na)
Linear (Ca-K)
Linear (Ca-Li)
50
40
30
20
10
0
-10
-20
-30
-40
-2
-1.5
-1
-0.5
log activity ratio
0
0.5
1
For each group compute the following:
Component
n1
 y  (Y  Y )
2
i
n1
 x  (X
2
n1
 xy  ( X
b1
i
i
Ca-Li
Ca-Na
Ca-K
Sr-Na
Pooled Within
(sum)
311.33
1096.97
2180.13
2034.63
5623.06
0.727
2.461
4.703
4.639
12.53
15.02
51.85
100.63
96.80
264.30
20.66
21.07
21.39
20.87
bwithin  21.09
2
i
 Xi)
2
 X i )(Yi  Y )
For each group compute the following:
Component
n1
 yˆ  (Yˆi  Yi ) 2
2
Ca-Li
Ca-Na
Ca-K
Sr-Na
Pooled(sum)
310.43
1092.43
2152.84
2020.02
5575.73
n1
 yˆ
( ( X i  X i )(Yi  Y )) 2
2
within
n1
 ( X
n1
 (Yi  Yˆi ) 2
n1
 xy
total
a
i
 Xi)

2
0.898
2
(274.30)
 5574.93
12.53
4.54
  ni ( X i  X )(Yi  Y )  242.46
 d
d
2
YX
5623.06  5575.73  47.33
 5623.06  5574.93  48.13
SS among _ b 's  48.13  47.33  0.79
2
YX _ within
27.29
14.60
47.33
We obtain
 xy
among
 xy
among
n1
 xytotal   xywithin  242.45  264.30  21.85
We calculate unexplained sums of squares for these two levels of
variation:
d
2
YX _ total
n1
 y 2 total 
n1
( xytotal ) 2
n1
2
x
 total
(242.57) 2
 6013.72 
 1816.71
14.006
n1
2
2
2
y

y

y
among
total


 within  6013.72  5623.06  390.65
d
2
YX _ among
n1
 y 2 among 
( xyamong ) 2
2
x
 among
(21.84) 2
 390.65 
 67.309
1.48
We test the null hypothesis that there are no differences among sample
means Y when these are adjusted for a common X and a common
regression line:
2
2
2
d

d

d
 YX (adj)  YXtotal  YX _ within  1816.71  48.129  1768.6
Mean _ squareadjusted_ means 
Mean _ squareerror 
2
d
 YX (adj)
a 1
2
d
 YX ( within)
a
 n  a 1
1768.56

 598.53
3

48.1
 3.008
16
i
Fs 
mean _ squareadjusted_ means
mean _ squarewithin
598.53

 195.98
3.008
Sokal and Rohlf, 2000. Biometry
The output of R:
X
Group
Residuals
Df Sum Sq Mean Sq F value
Pr(>F)
1 4197.0 4197.0 1395.25 < 2.2e-16 ***
3 1768.6
589.5 195.98 8.005e-13 ***
16
48.1
3.0
Download