Analysis of covariance (ANCOVA)

TODO

  • link to anovaSStypes

Install required packages

car, phia, multcomp, effectsize

Test the effects of group membership and of covariate

Visually assess the data

plot of chunk rerAncova01
plot of chunk rerAncova01
plot of chunk rerAncova01
plot of chunk rerAncova01

Type I sum of squares

Analysis of Variance Table

Response: DVpost
          Df Sum Sq Mean Sq F value   Pr(>F)   
IV         2 240.47  120.23  4.1332 0.027629 * 
DVpre      1 313.37  313.37 10.7723 0.002937 **
Residuals 26 756.33   29.09                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Type II/III sum of squares

Since no interaction is present in the model, SS type II and III are equivalent here.

Using Anova() from package car

Anova Table (Type III tests)

Response: DVpost
            Sum Sq Df F value   Pr(>F)   
(Intercept)   0.00  1  0.0001 0.991035   
IV          217.15  2  3.7324 0.037584 * 
DVpre       313.37  1 10.7723 0.002937 **
Residuals   756.33 26                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Using model comparisons for SS type II

Analysis of Variance Table

Model 1: DVpost ~ DVpre
Model 2: DVpost ~ IV + DVpre
  Res.Df    RSS Df Sum of Sq      F  Pr(>F)  
1     28 973.48                              
2     26 756.33  2    217.15 3.7324 0.03758 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table

Model 1: DVpost ~ IV
Model 2: DVpost ~ IV + DVpre
  Res.Df     RSS Df Sum of Sq      F   Pr(>F)   
1     27 1069.70                                
2     26  756.33  1    313.37 10.772 0.002937 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Test individual regression coefficients


Call:
lm(formula = DVpost ~ IV + DVpre, data = dfAnc)

Residuals:
     Min       1Q   Median       3Q      Max 
-10.6842  -3.9615   0.6448   3.8773   9.9675 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  -3.6704     3.7525  -0.978  0.33703   
IVPlacebo     4.4483     2.4160   1.841  0.07703 . 
IVWL          6.4419     2.4133   2.669  0.01292 * 
DVpre         0.6453     0.1966   3.282  0.00294 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.393 on 26 degrees of freedom
Multiple R-squared:  0.4227,    Adjusted R-squared:  0.3561 
F-statistic: 6.346 on 3 and 26 DF,  p-value: 0.002252
                  2.5 %    97.5 %
(Intercept) -11.3836718  4.042941
IVPlacebo    -0.5178144  9.414373
IVWL          1.4812101 11.402537
DVpre         0.2411673  1.049464

Vsisualize ANCOVA coefficients

plot of chunk rerAncova02
plot of chunk rerAncova02

Effect size estimate

\(\hat{\omega}^{2}\) for the group effect

Using SS type II

Parameter | Omega2 |       90% CI
---------------------------------
IV        |   0.14 | [0.00, 0.32]
DVpre     |   0.21 | [0.03, 0.42]
Parameter | Omega2 (partial) |       90% CI
-------------------------------------------
IV        |             0.17 | [0.00, 0.37]
DVpre     |             0.25 | [0.05, 0.45]

Planned comparisons between groups

Adjusted group means

       IV adjusted mean std. error
1    SSRI      7.536616   1.707096
2 Placebo     11.984895   1.706832
3      WL     13.978489   1.705586

Planned comparisons


     Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: User-defined Contrasts


Fit: aov(formula = DVpost ~ IV + DVpre, data = dfAnc)

Linear Hypotheses:
                    Estimate Std. Error t value  Pr(>t)   
SSRI-Placebo <= 0      4.448      2.416   1.841 0.03852 * 
SSRI-WL <= 0           6.442      2.413   2.669 0.00646 **
SSRI-0.5(P+WL) <= 0   10.890      4.183   2.603 0.00753 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Adjusted p values reported -- none method)

Detach (automatically) loaded packages (if possible)

Get the article source from GitHub

R markdown - markdown - R code - all posts