Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to run a Repeated measure ANCOVA adjusted for age and sex

    Hi every one, Hope I can find some help here,

    In a clinical interventional trial on physical training, we would like to compare the effectiveness of a personalized intervention (PERS) versus a standard intervention (STAND) on the physical performance (fitness).
    The trial lasts 6 months and the participants (n=100, randomized into PERS or STAND with 1:1 ratio) are evaluated at the beginning, middle and end of the study.

    Analysis: Mean changes in physical performance from baseline using a repeated measures analysis of covariance (ANCOVA) model, adjusted for age and sex, including the effects of the group intervention and time (baseline, mid and post-intervention).

    My question:
    I don't know how to program it in STATA in the command line panel nor in the ''statistics'' tabs at the top of the software.

    can someone explain me both please

    Thank you a lot for your help

  • #2
    If you do not have dropout or missed visits during the follow-up, then you could use xtreg , fe in order to examine changes from baseline; otherwise, you would use xtmixed to fit a repeated-measures ANOVA model to the performance values.

    The syntax for both is given in the code below, which you can run in order to see how it works. Begin at the "Begin here" comment; the busyness at the beginning is just to create a toy dataset with known parameters for use in the illustration.
    Code:
    version 17.0
    
    clear *
    
    // seedem
    set seed 1094723157
    
    // Participants
    quietly set obs 100
    generate byte participant_id = _n
    generate double u = rnormal(100, 15)
    
    generate double age = runiform(18, 45)
    generate byte sex = rbinomial(1, 0.5)
    label define Sexes 0 M 1 F
    label values sex Sexes
    
    // Treatment groups
    generate byte group = mod(_n, 2)
    label define Interventions 0 Standard 1 Pesonalized
    label values group Interventions
    
    // Follow-up intervals
    quietly expand 3
    bysort participant_id: generate byte month = (_n - 1) * 3
    label define Visits 0 Beginning 3 Middle 6 "End of Study"
    label values month Visits
    
    // Physical performance
    generate double performance = u + age * 0 + sex * 0 + ///
        group * 0 + month * 5 + group * month * 5 + ///
            rnormal(0, 15)
    
    format age performance %3.0f
    
    list participant_id age sex group month performance ///
        if participant_id == participant_id[1], noobs abbreviate(20)
    
    *
    * Begin here
    *
    
    *
    * "Analysis: Mean changes in physical performance from baseline"
    *
    xtreg performance c.age i.sex i.group##i.month, i(participant_id) fe
    contrast month@group, effects cformat(%3.0f)
    
    // Sanity check: manually calculated mean within-participant change-from-baseline values
    by participant_id : generate double delta = performance - performance[1]
    version 16.1: table group month if month > 0, contents(mean delta) format(%3.0f)
    
    *
    * "Repeated measure ANCOVA adjusted for age and sex"
    *
    mixed performance c.age i.sex i.group##i.month || participant_id: , noconstant ///
        reml dfmethod(kroger) ///
        residuals(exchangeable) ///
            nolrtest nolog
    contrast month@group, effects cformat(%3.0f) small
    
    exit
    The contrast postestimation command is what gives you the mean (predicted) changes in performance from baseline for each intervention group at each postintervention follow-up interval.

    Comment


    • #3
      thank you a lot Joseph, it helps me a lot.

      can I abuse a bit more of your time and knowledge please...

      1/ I run your line command and it works perfectly (thanks again) : how can I do it with the window in Stata : ''Statistics'' then ''multilevel mixed-effect models'' .... and ?

      2/ Where can I find the interaction "time x group effect" with the F statistics and p value ?

      3/ can I also run this line ? and how to introduce age and sex as covariate ?

      anova performance group / participant_id| group month group#month, repeated(month)


      thank you





      Comment


      • #4
        Originally posted by Flo Bzh View Post
        1/ I run your line command and it works perfectly (thanks again) : how can I do it with the window in Stata : ''Statistics'' then ''multilevel mixed-effect models'' .... and ?
        1. On the "Model" tab (main menu), first click on the Restricted maximum likelihood (REML)" radio button at the top from the "Estimation method" radio-button pair.

        2. Moving down, either type in the outcome variable or else select it on the dropdown list.

        3a. Moving rightward from there, do the same for the explanatory variables.If you cannot bring yourself to type the c. in front of the age variable name, then click the three-dot button at the righthand side in order to bring up a submenu and select the "continuous variable" radio button from the "Type of variable" radio-button group and then select the variable's name from the "Variables" dropdown list.

        3b. Follow the same routine for the sex covariate: either select it on the main menu and type i. in front of it or go to the popup submenu and leave the "Type of variable" on the default "Factor variable" radio button.

        3c. Ditto if you don't want to type the double-octothorpes for the interaction term: on the popup submenu, select "2-way full factorial" on the "Specification:" listbox and select group for "Variable 1" and month for "Variable 2 listboxes and then click the "Add to varlist" button in the lower righthand side before returning to the main menu by clicking the "OK"button.

        4. Then click the "Create" button to the right of the "Random-effects equation" section and type in or select particpant_id.

        5. Moving downward, in the "Options" section, tick the checkbox for "Compute the degrees of freedom" and select "Kenward-Roger" on the dropdown list.

        6. Still in the "Options" section, tick the "Residuals" checkbox and select "Exchangeable" on the dropdown list.

        7. Click on either "Submit" or "OK" to fit the model.



        2/ Where can I find the interaction "time x group effect" with the F statistics and p value ?
        After xtreg , fe, this:
        Code:
        testparm i.group#i.month
        After mixed, this:
        Code:
        testparm i.group#i.month, small


        3/ can I also run this line ?

        anova performance group / participant_id| group month group#month, repeated(month)
        Yes.


        and how to introduce age and sex as covariate ?
        Code:
        anova performance c.age sex group / participant_id|group month group#i.month
        and ignore the test statistics and p-values for the two covariates (they're not valid).

        Alternatively,
        Code:
        xtreg performance c.age i.sex i.group##i.month, i(participant_id) be
        and if you want F test statistics instead of Student's t, then
        Code:
        test age
        contrast sex group

        Comment


        • #5
          Dear Joseph

          It's amazing how much time and energy you've saved me. I have learned a lot from your suggestions. I should have registered earlier on this forum which is a great community to help each other.
          THANK YOU

          Comment


          • #6
            Hello Joseph,

            May I ask a follow-up question to the syntax you provided please.

            From

            Code:
            anova performance group / participant_id| group month group#month, repeated(month)
            To

            Code:
            anova performance c.age sex group / participant_id|group month group#i.month
            1. Why did you drop
            Code:
            repeated(month)
            ?

            2. Why did you make
            Code:
            month
            Code:
            i.month
            ?

            Thank you so much!

            Comment


            • #7
              Originally posted by Eric Chua View Post
              1. Why did you drop repeated(month)?
              Probably a copy-and-paste glitch, I don't recall.

              In practice, I don't use the option that much; I'm more inclined to model the residual covariance structure than to adjust test statistics for violation of the sphericity assumption. (In practice, data are too messy to use anova much.)

              2. Why did you make month i.month?
              Ditto.

              Comment


              • #8
                Dear Joseph Coveney ,
                can I ask you some random questions here related to the model that you fited for me months ago.
                1/in the mixed procedure, why the dependant variable is ''performance'' instead of ''the change from baseline to 6-month'' ? is that matter ?
                2/where is the repeated measures analysis statement in the model ? is it assume by i.group##i.month
                3/why the residual are ''exchangable'' ?
                4/can we add an ''unstructured" covariance model ?

                Thank you
                Florent

                Comment


                • #9
                  Originally posted by Flo Bzh View Post
                  1/in the mixed procedure, why the dependant variable is ''performance'' instead of ''the change from baseline to 6-month'' ? is that matter ?
                  Google harrell "change scores" and take a look at the first hit.

                  2/where is the repeated measures analysis statement in the model ? is it assume by i.group##i.month
                  There's no such statement. It is specified in declaring participant_id a random effect.

                  3/why the residual are ''exchangable'' ?
                  It is conventional in mixed-model ANOVA to assume that covariance structure for the residuals. It is parsimonious and often adequate.

                  4/can we add an ''unstructured" covariance model ?
                  Yes.

                  Comment

                  Working...
                  X