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: Re: Repeated Measures ANOVA: contrasts


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: Repeated Measures ANOVA: contrasts
Date   Sun, 2 Feb 2014 18:36:29 +0900

David C Airey wrote:

I didn't read far enough in the help file! Page 362 and beyond
for -contrast- has examples with evaluated fractions like
`=1/3' in the linear combination.

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

I didn't read that far either.  Anyway, if there is substantial autocorrelation,
and if the difference between the average of the first two observations and the
following three is of primary scientific  interest, then the original poster
would perhaps be better off just computing the averages for each volunteer and
performing a paired t-test.  -manova- and -manovatest- (or -contrast-) are out,
with eight volunteers and seven intervals.

Joseph Coveney

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

. 
. program define simem, rclass
  1.     version 12.1
  2.     syntax
  3. 
.     drop _all
  4.         set obs 8
  5.     generate byte pid = _n
  6.     generate double fmt1 = rnormal()
  7.     forvalues i = 2/7 {
  8.         generate double fmt`i' = 0.5 * fmt`=`i'-1' + ///
>             sqrt(0.75) * rnormal()
  9.     }
 10.     tempvar a b
 11.     generate double `a' = (fmt1 + fmt2) / 2
 12.     generate double `b' = (fmt3 + fmt4 + fmt5) / 3
 13.     ttest `a' = `b'
 14.     tempname p
 15.     scalar define `p' = r(p)
 16.     drop `a' `b'
 17.     quietly reshape long fmt, i(pid) j(time)
 18.     xtreg fmt i.time, i(pid) fe
 19.     test (1.time + 2.time) / 2 = (3.time + 4.time + 5.time) / 3
 20.     return scalar l = r(p)
 21.     return scalar t = `p'
 22. end

. 
. simulate t = r(t) l = r(l), reps(10000) nodots: simem

      command:  simem
            t:  r(t)
            l:  r(l)


. 
. foreach var of varlist l t {
  2.         generate byte pos_`var' = `var' < 0.05
  3. }

. 
. summarize pos_*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       pos_l |     10000        .105    .3065687          0          1
       pos_t |     10000       .0511    .2202127          0          1

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