e.- ANCOVA
Objetive
The function ANCOVA performes an ANOVA with covariate allowing also the estimation of the interaction effect of covariant variable with the intergroup factor defined by the user.
ANCOVA
We start from the multivariate analysis of variance and split-plot design previosuly commented on OBrienKaiser database. To this database we add a simulated covariant variable named cova. This covariant have been stored in the external file obrienkaiser_covariante.txt.
dat = OBrienKaiser
covariate=read.file.fnc('obrienkaiser_covariante.txt',
have.names=T)
In this file we have two variables: subject and cova. The variable subject is very important because it will allow us to link this database to any other containing the same pairing variable. For this reason we need to create this variable in our original database. We will do this:
dat$subject=paste('sub',1:16,sep='')
Now we can merge two databases using the variable subject as pairing variable for both files.
datos=merge.data.fnc(dat, covariate,
add.var=T, pairing.var='subject')
We can carry out the estimation of our ANCOVA model. First we have to create the between.factor and within.factor objects of our experiment.
between.factor = c('treatment','gender')
within.factor= list( phase= c('before','after','folowing'), hour= 1:5 )
Anova.fnc(dat, between.factor=between.factor,
within.factor=within.factor,
col.start.rm=4, type=2,
covariate='cova')
#---------------------------------------------------------------------------
# ANALYSIS OF VARIANCE
#---------------------------------------------------------------------------
Univariate Type II Repeated-Measures ANOVA Assuming Sphericity
SS num Df Error SS den Df F Pr(>F)
(Intercept) 7260.0 1 26.127 9 2500.8243 2.565e-12 ***
cova 201.9 1 26.127 9 69.5574 1.585e-05 ***
treatment 117.5 2 26.127 9 20.2430 0.0004666 ***
gender 4.7 1 26.127 9 1.6339 0.2331495
treatment:gender 42.1 2 26.127 9 7.2437 0.0133453 *
fase 167.5 2 74.688 18 20.1840 2.523e-05 ***
cova:fase 5.6 2 74.688 18 0.6736 0.5222758
treatment:fase 75.9 4 74.688 18 4.5751 0.0100358 *
gender:fase 3.3 2 74.688 18 0.3937 0.6802117
treatment:gender:fase 11.7 4 74.688 18 0.7030 0.6000930
hora 106.3 4 62.023 36 15.4236 1.941e-07 ***
cova:hora 0.5 4 62.023 36 0.0691 0.9908807
treatment:hora 1.1 8 62.023 36 0.0827 0.9995030
gender:hora 2.6 4 62.023 36 0.3816 0.8203228
treatment:gender:hora 7.3 8 62.023 36 0.5263 0.8287364
fase:hora 11.1 8 87.811 72 1.1360 0.3501725
cova:fase:hora 8.4 8 87.811 72 0.8563 0.5570796
treatment:fase:hora 7.3 16 87.811 72 0.3723 0.9849745
gender:fase:hora 7.1 8 87.811 72 0.7313 0.6634827
treatment:gender:fase:hora 15.9 16 87.811 72 0.8147 0.6649304
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
When you enter a covariant the function generates a panel graph for each of the effects from which the user can evaluate both the adequacy of the linear relationship between the covariant variable and the dependent variable. We can check the equal regression slopes between J levels of each factor. Thus we see that there is indeed linear relationship between the covariant and the dependent (which warn us about the adequacy of running an ANCOVA intead of an ANOVA) and moreover we can assume the homogeneity of slopes.
If we compare the effects found in this ANCOVA with Split-Plot ANOVA previously performed we see that in one hand the test statistic for the effect of treatment has increased considerably and it appears an nonexistent interaction in ANOVA: treatment x gender (p <0.05 )
If wathing these graphs we suspect the existence of interaction between covariant with some factor, such interaction could be included in the model in the argument cova.by.iv indicating the name of this factor. We will do assuming heterogeneity of the slopes of the covariant with the between factor gender.
Anova.fnc(dat, between.factor=between.factor,
within.factor=within.factor,
col.start.rm=4, type=2,
covariate='cova',
cova.by.iv='gender')
Univariate Type II Repeated-Measures ANOVA Assuming Sphericity
SS num Df Error SS den Df F Pr(>F)
(Intercept) 7260.0 1 25.738 8 2256.6274 4.264e-11 ***
cova 201.9 1 25.738 8 62.7654 4.684e-05 ***
gender 4.7 1 25.738 8 1.4743 0.259289
treatment 105.8 2 25.738 8 16.4456 0.001465 **
cova:gender 0.4 1 25.738 8 0.1212 0.736740
As we suspected there is no interaction between the covariant and gender factor (the slope is homogeneous for both levels of gender). The most appropriate model is the previous ANCOVA.