# [R] (two way) ANCOVA and subsequent multiple comparison tests

lindsay hanford lindsay.hanford at gmail.com
Wed Jan 14 20:59:53 CET 2015

```Hello R Community!

I am an intermediate-level R user and I am trying to figure out how program
a two-way (Group and MCCB score) ANCOVA analysis and subsequent post-hoc
analysis.
My factors:
Group (2 levels)
Score (2 levels)
Covariates:
Age (continuous)
ICV (continuous)
Sex (M/F)
Y:
GMV(continuous)

I am interested in looking at the interaction of these two factors and have
set up my ANCOVA as follows:

*model1 <-aov(GMV~ GROUP*Score +Age +ICV +Sex, data=dataframe)*
*summary(model1) *

which has given me some very exciting results...

Analysis of Variance Table
Response: GMV
Df    Sum Sq   Mean Sq F value    Pr(>F)
GROUP       1 104219614 104219614  25.119 1.739e-06 ***
Score         1 231825545 231825545  55.875 1.042e-11 ***
Sex        1  49112001  49112001  11.837 0.0007828 ***
Age         1 165812317 165812317  39.964 3.882e-09 ***
ICV         1 283849872 283849872  68.414 1.416e-13 ***
GROUP:Score  1  30802470  30802470   7.424 0.0073292 **
Residuals 129 535224714   4149029
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I need to control for multiple comparisons as I will be trying other
variables in place of GMV. From the forum, TukeyHSD() will not work as I
have covariates. The glth() shows promise, however, I am not sure if the
resulting statistics are what I am looking for?

*mc1<-mcalinfct(model1, "GROUP")*
*summary(glht(model1, linfct=mc1))*

Simultaneous Tests for General Linear Hypotheses
Fit: aov(formula = GMV ~ GROUP * Score + Age + ICV +Sex, data =dataframe)

Linear Hypotheses:
Estimate Std. Error t value Pr(>|t|)
1 == 0   -844.9      392.2  -2.154   0.0331 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)

I believe this means that the difference in GMVs is statistical significant
between my groups (pcor = 0.03). Does this also mean that my interaction is
significant? If not, how do I test for that? My intention is to be able to
create a graphic of this interaction similar to the attached.

I tried using previous posts from the help forum. I believe this post holds
the answer, but it is beyond my R programming ability. If someone could
help explain...

http://r.789695.n4.nabble.com/Multiple-comparisons-for-a-two-factor-ANCOVA-td1593039.html
http://cran.r-project.org/web/packages/HH/HH.pdf

Thanks!

Lindsay

--
Lindsay Hanford, BSc, PhD Candidate
McMaster Integrative Neuroscience Discovery & Study | *Department of
Psychology, Neuroscience & Behaviour *
McMaster University *|* 1280 Main Street West, PC329 Psychology Building *|*
Hamilton, ON, L8S 4L8
905 525 9140 x24784 *|* lindsay.hanford at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen shot 2015-01-14 at 2.48.39 PM.png
Type: image/png
Size: 17300 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150114/f04769bd/attachment.png>
```

More information about the R-help mailing list