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]

Re: st: Re: Re: Repeated Measures ANOVA: contrasts


From   "Airey, David C" <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: Re: Re: Repeated Measures ANOVA: contrasts
Date   Sun, 2 Feb 2014 20:06:54 +0000

.

Vincent,

Here is some code to help with your first question:

clear
set seed 1967
set obs 8
egen id = seq(), from(1) to(8) block(1)
gen id_random = 5*rnormal()
expand 7
sort id
egen time = seq(), from(1) to(7) block(1)
gen error = 2*rnormal()
gen y = 10 + id_random + 2*time + error
sort id time
graph twoway connected y time, connect(L)
anova y time id, repeated(time)
contrast {time `=1/2' `=1/2' `=-1/3' `=-1/3' `=-1/3' 0 0}, lincom
contrast {time 1.5 1.5 -1 -1 -1 0 0}, lincom // same test stat, diff estimate
collapse (mean) y, by(time)
display (y[1]+y[2])/2 - (y[3]+y[4]+y[5])/3 // data balanced
display 3*((y[1]+y[2])/2 - (y[3]+y[4]+y[5])/3)

As for the second question, MANOVA may not compute when there are not 
enough df (too few persons for the number of time points).

-Dave

. contrast {time `=1/2' `=1/2' `=-1/3' `=-1/3' `=-1/3' 0 0}, lincom

Contrasts of marginal linear predictions

Margins      : asbalanced

------------------------------------------------
             |         df           F        P>F
-------------+----------------------------------
        time |          1       62.18     0.0000
             |
 Denominator |         42
------------------------------------------------

--------------------------------------------------------------
             |   Contrast   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        time |
        (1)  |  -5.353632   .6789456     -6.723799   -3.983464
--------------------------------------------------------------

. 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       62.18     0.0000
             |
 Denominator |         42
------------------------------------------------

--------------------------------------------------------------
             |   Contrast   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        time |
        (1)  |  -16.06089   2.036837      -20.1714   -11.95039
--------------------------------------------------------------

. collapse (mean) y, by(time)

. display (y[1]+y[2])/2 - (y[3]+y[4]+y[5])/3
-5.3536318

. 
end of do-file

. do "/var/folders/86/_7btv8rj39q5pc1mc13_39_40000gn/T//SD13736.000000"

. display 3*((y[1]+y[2])/2 - (y[3]+y[4]+y[5])/3)
-16.060895




*
*   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