2
$\begingroup$

This is a subset of my dataset:

> head(db,20)
   YEAR RING  CO2       Nup
1  1998    1 elev  6.441205
2  1998    2 elev  6.939212
3  1998    3  amb  6.370073
4  1998    4  amb  6.816244
5  1998    5  amb  4.839825
6  1999    1 elev  7.032590
7  1999    2 elev  7.473761
8  1999    3  amb  5.791581
9  1999    4  amb  8.209857
10 1999    5  amb  5.607706
11 2000    1 elev  9.457697
12 2000    2 elev  7.509605
13 2000    3  amb  5.938662
14 2000    4  amb  7.868018
15 2000    5  amb  8.397162
16 2001    1 elev 12.085675
17 2001    2 elev  7.136464
18 2001    3  amb  5.624912
19 2001    4  amb  7.483332
20 2001    5  amb  9.395876

The aim of my analysis is to find out if there is an effect of the CO2 treatment on Nup, but furthermore, I need to know in which YEARS the effect of CO2 is significant. My model would hence be:

mod <- lm(Nup~CO2*YEAR)
anova(mod)

Which renders a significant interaction. In the past I have used Tukey inside the function glht {multcomp}, but only with one factor. How can I do Tukey post-hoc multiple comparisons to find out what are the years in which the effect is significant?

$\endgroup$
3
$\begingroup$

The lsmeans package makes this pretty simple:

library(lsmeans)
lsmeans(mod, pairwise ~ CO2 | YEAR)

The tukey adjustment is the default.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.