Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: Repeated Measures ANOVA: contrasts


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: Repeated Measures ANOVA: contrasts
Date   Sat, 1 Feb 2014 00:44:53 +0900

Vincent Koppelmans wrote:

I have longitudinal data (7 time points) from 8 subjects belonging to the same 
group. I would like to compare time points 1 and 2 versus 3, 4, and 5. 

I used: 

anova FMT time ID, repeated(time) bse(ID)
contrast time, effect

to compare time points mutually. (ID is subject ID number, FMT is my outcome 
measure)

Is it possible to create a contrast (e.g. 1.5 1.5 -1 -1 -1 0 0) to compare time
points 1 and 2 versus 3, 4, and 5?

--------------------------------------------------------------------------------

You can write custom contrasts.  Something like that below should work.  (Start
at the "Begin Here" section.  The stuff before is just set-up.)

Joseph Coveney


. version 13.1

. 
. clear *

. set more off

. set seed `=date("2014-01-31", "YMD")'

. quietly set obs 8

. 
. generate byte pid = _n

. forvalues i = 1/7 {
  2.     generate double fmt`i' = rnormal()
  3. }

. quietly reshape long fmt, i(pid) j(time)

. 
. anova fmt pid time, repeated(time)

                           Number of obs =      56     R-squared     =  0.2208
                           Root MSE      = .931711     Adj R-squared = -0.0204

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |   10.331744    13  .794749535       0.92     0.5453
                         |
                     pid |  2.82247193     7  .403210276       0.46     0.8545
                    time |  7.50927202     6  1.25154534       1.44     0.2218
                         |
                Residual |  36.4595877    42  .868085422   
              -----------+----------------------------------------------------
                   Total |  46.7913317    55  .850751485   


Between-subjects error term:  pid
                     Levels:  8         (7 df)
     Lowest b.s.e. variable:  pid

Repeated variable: time
                                          Huynh-Feldt epsilon        =  1.0158
                                          *Huynh-Feldt epsilon reset to 1.0000
                                          Greenhouse-Geisser epsilon =  0.5281
                                          Box's conservative epsilon =  0.1667

                                            ------------ Prob > F ------------
                  Source |     df      F    Regular    H-F      G-G      Box
              -----------+----------------------------------------------------
                    time |      6     1.44   0.2218   0.2218   0.2569   0.2689
                Residual |     42
              ----------------------------------------------------------------

. 
. *
. * Begin Here
. *
. contrast {time 1.5 1.5 -1 -1 -1 0 0}, lincom

Contrasts of marginal linear predictions

Margins      : asbalanced

------------------------------------------------
             |         df           F        P>F
-------------+----------------------------------
        time |          1        2.43     0.1266
             |
 Denominator |         42
------------------------------------------------

--------------------------------------------------------------
             |   Contrast   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        time |
        (1)  |  -1.406213   .9021253     -3.226775    .4143497
--------------------------------------------------------------

. 
. // For the estimate & its CIs, though, you'll probably want this one:
. local mot = -1/3

. contrast {time 0.5 0.5 `mot' `mot' `mot' 0 0}, lincom

Contrasts of marginal linear predictions

Margins      : asbalanced

------------------------------------------------
             |         df           F        P>F
-------------+----------------------------------
        time |          1        2.43     0.1266
             |
 Denominator |         42
------------------------------------------------

--------------------------------------------------------------
             |   Contrast   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        time |
        (1)  |  -.4687376   .3007084     -1.075592    .1381166
--------------------------------------------------------------

. 
. exit

end of do-file

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index