Statalist


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

st: RE: RE: RE: Covariates in ANOVAs


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Covariates in ANOVAs
Date   Fri, 15 May 2009 23:42:19 +0900

Miss Gina Micke wrote:

Thanks for your input. Maybe I didn't make myself clear enough re "age range".
Age range refers to actual age in days at each measurement. As all subjects were
measured on the same day at each measurement event, the difference between
subject ages is the same at each measurement event, so age at first measurement
would be the data in the "age range" variable. Do you still think this should be
inlcuded as a categorical variable?

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

No.  It would be continuous.

How to set up repeated-measures ANCOVA with a continuous baseline covariate
using -anova- crops up on the List every now and then.  See, for example,
www.stata.com/statalist/archive/2006-02/msg00973.html and the earlier Statalist
post cited there.  

In your particular case, you'll want -anova- syntax like that illustrated below.
I've changed the delimiter in order to allow the =anova- syntax for the
repeated-measures ANCOVA model to be displayed more clearly.  You can substitute
your own variable names and run the -anova- command directly.

Joseph Coveney

/* Create fictional dataset for illustration */
clear *
set more off
set seed `=date("2000-05-15", "YMD")'
set obs 24

generate byte infant_id = _n
generate double infant_u = 1 * invnormal(runiform())

generate byte sex = mod(_n, 2)

generate int baseline_age = 30 + floor(30 * runiform())

generate byte treatment_group = _n > _N / 2

#delimit ;

forvalues time = 1/6 {;
  generate double response`time' = 50
    + 0   * sex
    + 0.5 * baseline_age
    + 0   * treatment_group
    + 0   * `time'
    + 0   * treatment_group * `time'
    + 0   * sex * treatment_group
    + 0   * sex * treatment_group * `time'
    + 1   * invnormal(runiform());
};

reshape long response, i(infant_id) j(observation_interval);

/* Begin here */

anova response 

  baseline_age 

  sex 
  treatment_group 
  sex*treatment_group / infant_id|sex*treatment_group

  observation_interval 

  sex*observation_interval 

  treatment_group*observation_interval

  sex*treatment_group*observation_interval

  , continuous(baseline_age)

  repeated(observation_interval);

delimit cr

exit



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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index