[R-sig-ME] lme posthoc constrasts for interaction effects group*time

Nicholas Lewin-Koh nikko at hailmail.net
Tue Jun 22 21:36:35 CEST 2010


Hi Chris,
No, you want to leave the main effects in.
Nicholas

On Tue, 22 Jun 2010 20:44 +0200, "Chris Kleier"
<chris.kleier at gmail.com> wrote:

  Hi Nicolas,
  You're right, I'll should go for the manual contrast matrix,
  and correct for multiple comparisons manually.
  This is the matrix created using the contrast package for
  'group' (taking into account the interaction effects as well).
                              (Intercept) groupStroke large
  groupStroke small    time groupStroke large:time groupStroke
  small:time
  Stroke large - Control                0
  1                 0    0
  1                      0
  Stroke small - Control               0
  0                 1    0
  0                      1
  Stroke small - Stroke large        0
  -1                 1    0
  -1                      1
  Just to be sure: to get the interaction effect contrasts ONLY,
  should I change the contrast to: ?
                              (Intercept) groupStroke large
  groupStroke small    time groupStroke large:time groupStroke
  small:time
  Stroke large - Control                0                 0
              0    0                      1
  0
  Stroke small - Control               0
  0                 0    0
  0                      1
  Stroke small - Stroke large        0                 0
           0    0                     -1                      1
  Thanks!
  Chris

On Tue, Jun 22, 2010 at 5:18 PM, Nicholas Lewin-Koh
<[1]nikko at hailmail.net> wrote:

  Hi Chris,
  If you look at the code I sent, the second part uses the
  contrast
  package to get
  the contrast matrix for testing within the interaction. mcp
  does not
  handle interactions (I think) but you can specifiy them more
  easily
  using the contrast package and then peel off the contrast
  matrix for use
  in multcomp.
  Nicholas

On Tue, 22 Jun 2010 16:57 +0200, "Chris Kleier"
<[2]chris.kleier at gmail.com> wrote:
 Hi Nicholas,
 Thanks for your help.
 I have been looking at the contrast library, however, we are
 interested in differences between interactions only and not
 between group and interactions together.
 In fact I would like:
 test <- glht( model, lin = mcp( "group:time"  = 'Tukey' ) )
 This quesion is in fact similar to the question posted before:

   [1][3]http://www.mail-archive.com/r-help@r-project.org/msg657
  20.h

 tml
 The mcp function is probably not able to manage interactions.
 Chris
On Fri, Jun 18, 2010 at 6:27 PM, Nicholas Lewin-Koh


<[2][4]nikko at hailmail.net> wrote:
 Hi,
 Try
 library(multcomp)
 test<-glht(model,lin=mcp(group="Tukey"))
 confint(test)
 However, that just tests the marginal effect of group.
 With interactions you want to test over time, probably a
 simultaneous
 interval.
 This will get you close:
 library(contrast)
 ctt<-contrast(model, a=list( day=c(0,3,7,21,49), group=c(Small
 Stroke",
 "Large Stroke")),
              b=list(day=c(0,3,7,21,49), group=c("Control",
 "Control")))
 ## Extract the contrast matrix
 cmtrx <- ctt$X
 ## Fit the contrasts using glht
 ttgl<-glht(model,lin=cmtrx)
 confint(ttgl)
 hope this helps.
 And do read the vignette in multcomp  :)
 Nicholas
 > Message: 2
 > Date: Thu, 17 Jun 2010 14:51:21 +0200

   > From: Chris Kleier <[3][5]chris.kleier at gmail.com>
   > To: R sig-mixed-models
  <[4][6]r-sig-mixed-models at r-project.org>

 > Subject: [R-sig-ME] lme posthoc constrasts for interaction
 effects
 >       group*time
 > Message-ID:
 >

   <[5]AANLkTilMkK9HJZqXDZimDzKCswXElxw__dUVQpSnW8FQ at mail.gmail.
  c


 om>
 > Content-Type: text/plain
 >
 > Hi all,
 >
 > Our dataset is a repeated measures design including 3 groups
 (a)
 > Controls,
 > (b) Small stroke and (c) Large stroke. We want to know if
 the group
 > behave
 > different over time.
 >
 > We first fitted a lme with fixed = group * time (see below).
 > Their was a significant interaction effect (see below as
 well; p < 0.05)
 >
 > In the next step we want to know which groups have
 significant
 > interactions
 > (Control - Stroke large, Control - Stroke small, Stroke
 small - Stroke
 > large), and their p-values + CIs.
 >
 > A posthoc Tukey, I think is fine. However, I do not know how
 to setup the
 > constrast matrix.
 >
 > These are the contrast names ( names( coef( model ) ) ):
 > "(Intercept)", "groupStroke large", "groupStroke small",
 "time",
 > "groupStroke large:time" "groupStroke small:time"
 >
 > I guess, the model has to be refitted to get a contrast for
 > "groupControl:time" as well, but I do not know how.
 >
 > Any solution known? (Probabily something in the direction
 of: model.2 <-
 > update( model, fixed = 0 + group * time ) )
 >
 > Thanks!
 >
 > Chris
 >
 >
 >
 >
 >
 > This is a print of the dataset:
 >
 >     subject        group       value day
 > 1       N03 Stroke small  0.47545500   0
 > 2       N04 Stroke small  0.38866500   0
 > 3       N19 Stroke small  0.64749800   0
 > 4       N20 Stroke small  0.50468600   0
 > 5       N22 Stroke small  0.55872300   0
 > 6       N03 Stroke small  0.01979970   3
 > 7       N04 Stroke small  0.05607250   3
 > 8       N19 Stroke small -0.04506370   3
 > 9       N20 Stroke small -0.33935400   3
 > 10      N22 Stroke small  0.22052700   3
 > 11      N03 Stroke small  0.29805300   7
 > 12      N04 Stroke small -0.24908100   7
 > 13      N19 Stroke small -0.02657290   7
 > 14      N20 Stroke small -0.19483200   7
 > 15      N22 Stroke small  0.50948000   7
 > 16      N03 Stroke small  0.13056600  21
 > 17      N04 Stroke small  0.33759500  21
 > 18      N19 Stroke small  0.14929200  21
 > 19      N20 Stroke small  0.25033100  21
 > 20      N22 Stroke small  0.71456800  21
 > 21      N03 Stroke small  0.39007100  49
 > 22      N04 Stroke small  0.33254400  49
 > 23      N19 Stroke small  0.27767600  49
 > 24      N20 Stroke small  0.33467500  49
 > 25      N22 Stroke small  0.52203500  49
 > 26      N03 Stroke small  0.29851100  70
 > 27      N04 Stroke small  0.50900200  70
 > 28      N19 Stroke small  0.51781700  70
 > 29      N20 Stroke small  0.69543700  70
 > 30      N22 Stroke small  0.49337000  70
 > 31      N01 Stroke large          NA   0
 > 32      N07 Stroke large  0.54930600   0
 > 33      N09 Stroke large  0.59703600   0
 > 34      N10 Stroke large  0.72751400   0
 > 35      N17 Stroke large  0.63878400   0
 > 36      N23 Stroke large  0.65749100   0
 > 37      N24 Stroke large  0.60945900   0
 > 38      N28 Stroke large          NA   0
 > 39      N01 Stroke large -0.31610900   3
 > 40      N07 Stroke large -0.33615700   3
 > 41      N09 Stroke large -0.24906400   3
 > 42      N10 Stroke large  0.33868700   3
 > 43      N17 Stroke large -0.31357300   3
 > 44      N23 Stroke large -0.13162800   3
 > 45      N24 Stroke large -0.45343700   3
 > 46      N28 Stroke large -0.18206700   3
 > 47      N01 Stroke large -0.05309070   7
 > 48      N07 Stroke large -0.83318300   7
 > 49      N09 Stroke large -0.49667100   7
 > 50      N10 Stroke large -0.48083200   7
 > 51      N17 Stroke large -0.28447000   7
 > 52      N23 Stroke large  0.01842660   7
 > 53      N24 Stroke large -0.50464400   7
 > 54      N28 Stroke large  0.16456100   7
 > 55      N01 Stroke large  0.24652600  21
 > 56      N07 Stroke large -0.31566500  21
 > 57      N09 Stroke large  0.39618900  21
 > 58      N10 Stroke large -0.30702200  21
 > 59      N17 Stroke large -0.28860100  21
 > 60      N23 Stroke large -0.23851000  21
 > 61      N24 Stroke large -0.00913697  21
 > 62      N28 Stroke large  0.43462600  21
 > 63      N01 Stroke large -0.20660100  49
 > 64      N07 Stroke large -0.13044900  49
 > 65      N09 Stroke large  0.24625000  49
 > 66      N10 Stroke large -0.28206200  49
 > 67      N17 Stroke large  0.29186400  49
 > 68      N23 Stroke large -0.14246600  49
 > 69      N24 Stroke large -0.11297700  49
 > 70      N28 Stroke large  0.32027300  49
 > 71      N01 Stroke large -0.00106427  70
 > 72      N07 Stroke large -0.17264000  70
 > 73      N09 Stroke large  0.26417500  70
 > 74      N10 Stroke large -0.11202200  70
 > 75      N17 Stroke large  0.16687700  70
 > 76      N23 Stroke large -0.24308300  70
 > 77      N24 Stroke large  0.00322026  70
 > 78      N28 Stroke large  0.34928100  70
 > 79      C01      Control          NA   0
 > 80      C02      Control          NA   0
 > 81      C03      Control          NA   0
 > 82      C04      Control          NA   0
 > 83      C05      Control          NA   0
 > 84      C06      Control          NA   0
 > 85      C07      Control          NA   0
 > 86      C09      Control          NA   0
 > 87      C10      Control          NA   0
 > 88      C32      Control          NA   0
 > 89      C01      Control  0.32387500   3
 > 90      C02      Control  0.48334200   3
 > 91      C03      Control  0.70698800   3
 > 92      C04      Control  0.00572262   3
 > 93      C05      Control  0.40416000   3
 > 94      C06      Control  0.36343800   3
 > 95      C07      Control  0.05064140   3
 > 96      C09      Control  0.84621500   3
 > 97      C10      Control  0.80675300   3
 > 98      C32      Control          NA   3
 > 99      C01      Control  0.23174400   7
 > 100     C02      Control  0.36959100   7
 > 101     C03      Control  0.43762800   7
 > 102     C04      Control  0.34187100   7
 > 103     C05      Control  0.74288400   7
 > 104     C06      Control  0.17692600   7
 > 105     C07      Control  0.60067600   7
 > 106     C09      Control  0.80314900   7
 > 107     C10      Control  0.81695500   7
 > 108     C32      Control  0.19029400   7
 > 109     C01      Control  0.45062600  21
 > 110     C02      Control  0.62884500  21
 > 111     C03      Control  0.33693200  21
 > 112     C04      Control  0.76098800  21
 > 113     C05      Control  0.59837500  21
 > 114     C06      Control  0.39328800  21
 > 115     C07      Control  0.55099400  21
 > 116     C09      Control  0.75411500  21
 > 117     C10      Control  0.72495100  21
 > 118     C32      Control  0.66503400  21
 > 119     C01      Control  0.63903900  49
 > 120     C02      Control          NA  49
 > 121     C03      Control  0.59655200  49
 > 122     C04      Control  0.42958700  49
 > 123     C05      Control  0.68408700  49
 > 124     C06      Control  0.45482700  49
 > 125     C07      Control  0.37217700  49
 > 126     C09      Control  0.75770400  49
 > 127     C10      Control  0.62059200  49
 > 128     C32      Control  0.68320900  49
 > 129     C01      Control  0.66179300  70
 > 130     C02      Control  0.34183000  70
 > 131     C03      Control  0.58543900  70
 > 132     C04      Control  0.62621700  70
 > 133     C05      Control  0.40610400  70
 > 134     C06      Control  0.32596100  70
 > 135     C07      Control  0.14847100  70
 > 136     C09      Control  0.79177000  70
 > 137     C10      Control  0.71970900  70
 > 138     C32      Control  0.56702700  70
 >
 > This is our model:
 >
 > model <- lme( na.action = na.omit, data = data, fixed =
 value ~ group *
 > time, random = ~1 | subject, correlation = corCAR1( form =
 ~time |
 > subject )
 > )
 >
 >
 >
 > anova( model )
 >
 >             numDF denDF  F-value p-value
 > (Intercept)     1    87 59.08836  <.0001
 > group           2    20 34.50706  <.0001
 > time            1    87 19.45032  <.0001
 > group:time      2    87  4.53603  0.0134
 >
 >
 >
 > intervals( model )
 >
 > Approximate 95% confidence intervals
 >
 >  Fixed effects:
 >                                lower          est.
 upper
 > (Intercept)             0.3677066515  0.4905816494
 0.613456647
 > groupStroke large      -0.9027833601 -0.7106686760
 -0.518553992
 > groupStroke small      -0.6705657199 -0.4490365094
 -0.227507299
 > time                   -0.0013629996  0.0009963115
 0.003355623
 > groupStroke large:time -0.0003754957  0.0031296769
 0.006634850
 > groupStroke small:time  0.0019261801  0.0059657552
 0.010005330
 > attr(,"label")
 > [1] "Fixed effects:"
 >
 >  Random Effects:
 >   Level: subject
 >                      lower      est.     upper
 > sd((Intercept)) 0.07377088 0.1227132 0.2041257
 >
 >  Correlation structure:
 >         lower      est.     upper
 > Phi 0.2035765 0.5971507 0.8957905
 > attr(,"label")
 > [1] "Correlation structure:"
 >
 >  Within-group standard error:
 >     lower      est.     upper
 > 0.1779472 0.2071400 0.2411220
 >
 >       [[alternative HTML version deleted]]
 >
 >
 >
 > ------------------------------
 >
 > _______________________________________________
 > R-sig-mixed-models mailing list

   > [6][7]R-sig-mixed-models at r-project.org
   >
  [7][8]https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

 >
 >
 > End of R-sig-mixed-models Digest, Vol 42, Issue 22
 > **************************************************
 >

  References
  1.
  [9]http://www.mail-archive.com/r-help@r-project.org/msg65720.h
  tml
  2. mailto:[10]nikko at hailmail.net
  3. mailto:[11]chris.kleier at gmail.com
  4. mailto:[12]r-sig-mixed-models at r-project.org
  5.
  mailto:[13]AANLkTilMkK9HJZqXDZimDzKCswXElxw__dUVQpSnW8FQ at mail.
  gmail.com
  6. mailto:[14]R-sig-mixed-models at r-project.org
  7.
  [15]https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

References

1. mailto:nikko at hailmail.net
2. mailto:chris.kleier at gmail.com
3. http://www.mail-archive.com/r-help@r-project.org/msg65720.h
4. mailto:nikko at hailmail.net
5. mailto:chris.kleier at gmail.com
6. mailto:r-sig-mixed-models at r-project.org
7. mailto:R-sig-mixed-models at r-project.org
8. https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
9. http://www.mail-archive.com/r-help@r-project.org/msg65720.html
  10. mailto:nikko at hailmail.net
  11. mailto:chris.kleier at gmail.com
  12. mailto:r-sig-mixed-models at r-project.org
  13.
  mailto:AANLkTilMkK9HJZqXDZimDzKCswXElxw__dUVQpSnW8FQ at mail.gmail.com
  14. mailto:R-sig-mixed-models at r-project.org
  15. https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models




More information about the R-sig-mixed-models mailing list