Announcement

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

  • Pre and post treatment

    Hello, I have done RCT random assigned to treatment A and B and follow at 1 and 2 months. I want to analyze whether there is difference between treatment A and B to affect (month1-baseline) and (month2-baseline).

    Group baseline month1 month2
    A 2 4 8
    A 6 5 10
    A 9 15 20
    B 3 5 7
    B 6 8 10

    I can't figure how to analyze these by Stata
    Thank you

  • #2
    As a for-instance, you could do something along the following lines. The null hypothesis you mention is tested in the group × time interaction term. Look at the grp#tim row in the column labeled "H-F" in table showing adjustments for departure from sphericity, below the main ANOVA output.

    .ÿ
    .ÿversionÿ16.1

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿinputÿstr1ÿGroupÿbyte(baselineÿmonth1ÿmonth2)

    ÿÿÿÿÿÿÿÿÿGroupÿÿbaselineÿÿÿÿmonth1ÿÿÿÿmonth2
    ÿÿ1.ÿAÿ2ÿ4ÿ8
    ÿÿ2.ÿAÿ6ÿ5ÿ10
    ÿÿ3.ÿAÿ9ÿ15ÿ20
    ÿÿ4.ÿBÿ3ÿ5ÿ7
    ÿÿ5.ÿBÿ6ÿ8ÿ10
    ÿÿ6.ÿend

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿencodeÿGroup,ÿgenerate(grp)label(Groups)

    .ÿrenameÿbaselineÿout0

    .ÿrenpfixÿmonthÿout

    .ÿ
    .ÿgenerateÿintÿpidÿ=ÿ_n

    .ÿquietlyÿreshapeÿlongÿout,ÿi(pid)ÿj(tim)

    .ÿ
    .ÿanovaÿoutÿgrpÿ/ÿpid|grpÿtimÿgrp#tim,ÿrepeated(tim)

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿÿ15ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.9440
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.68874ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.8694

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ288.62222ÿÿÿÿÿÿÿÿÿÿ8ÿÿÿ36.077778ÿÿÿÿÿ12.65ÿÿ0.0031
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿgrpÿ|ÿÿ18.677778ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ18.677778ÿÿÿÿÿÿ0.32ÿÿ0.6137
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpid|grpÿ|ÿÿ177.72222ÿÿÿÿÿÿÿÿÿÿ3ÿÿÿ59.240741ÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ73.688889ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ36.844444ÿÿÿÿÿ12.92ÿÿ0.0067
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿgrp#timÿ|ÿÿ6.4888889ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ3.2444444ÿÿÿÿÿÿ1.14ÿÿ0.3812
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ17.111111ÿÿÿÿÿÿÿÿÿÿ6ÿÿÿ2.8518519ÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ305.73333ÿÿÿÿÿÿÿÿÿ14ÿÿÿ21.838095ÿÿ


    Between-subjectsÿerrorÿterm:ÿÿpid|grp
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLevels:ÿÿ5ÿÿÿÿÿÿÿÿÿ(3ÿdf)
    ÿÿÿÿÿLowestÿb.s.e.ÿvariable:ÿÿpid
    ÿÿÿÿÿCovarianceÿpooledÿover:ÿÿgrpÿÿÿÿÿÿÿ(forÿrepeatedÿvariable)

    Repeatedÿvariable:ÿtim
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHuynh-Feldtÿepsilonÿÿÿÿÿÿÿÿ=ÿÿ0.8140
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿGreenhouse-Geisserÿepsilonÿ=ÿÿ0.5193
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿBox'sÿconservativeÿepsilonÿ=ÿÿ0.5000

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ------------ÿProbÿ>ÿFÿ------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿÿÿÿÿdfÿÿÿÿÿÿFÿÿÿÿRegularÿÿÿÿH-FÿÿÿÿÿÿG-GÿÿÿÿÿÿBox
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|ÿÿÿÿÿÿ2ÿÿÿÿ12.92ÿÿÿ0.0067ÿÿÿ0.0125ÿÿÿ0.0345ÿÿÿ0.0369
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿgrp#timÿ|ÿÿÿÿÿÿ2ÿÿÿÿÿ1.14ÿÿÿ0.3812ÿÿÿ0.3774ÿÿÿ0.3656ÿÿÿ0.3644
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿÿÿÿÿ6
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ----------------------------------------------------------------

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    Is there a reason why you're not using your name? This isn't homework, is it?

    Comment


    • #3
      Thanks, Joseph.
      I am new here and I mistakenly create my name but I can't edit the name now.
      It's an example I try to described my RCT, not a homework.

      I just start to use stata so I try hard to figure this line with syntex / | but I can't understand it's meaning.
      anova out grp/pid|grp tim grp#tim, repeated(tim)
      Could you explain more?

      And If I want to make the output like this
      "mean difference between group A and B in month 1 compared to baseline is xxxx +- xxxx mg/dL; p=xxxx"
      "mean difference between group A and B in month 2 compared to baseline is xxxx +- xxxx mg/dL; p=xxxx"
      What statistical test should I use?

      Thank you.

      Comment


      • #4
        Originally posted by Stata Beginner View Post
        anova out grp/pid|grp tim grp#tim, repeated(tim)
        Could you explain more?
        It's in the user's manual entry for anova under the section heading Repeated-measures ANOVA beginning on Page 48

        If I want to make the output like this
        "mean difference between group A and B in month 1 compared to baseline is xxxx +- xxxx mg/dL; p=xxxx"
        "mean difference between group A and B in month 2 compared to baseline is xxxx +- xxxx mg/dL; p=xxxx"
        What statistical test should I use?
        You could use test or lincom after fitting the model with anova.
        Code:
        help test
        help lincom
        for more information.

        If you used encode to numerically encode your grouping variable as I did above, then the numeric values for Groups A and B would be 1 and 2. So the contrasts for the two simple effects after the output shown above in #2 would be
        Code:
        lincom (2.grp#1.tim - 2.grp#0.tim) - (1.grp#1.tim - 1.grp#0.tim)
        and
        Code:
        lincom (2.grp#2.tim - 2.grp#0.tim) - (1.grp#2.tim - 1.grp#0.tim)
        .ÿlincomÿ(2.grp#1.timÿ-ÿ2.grp#0.tim)ÿ-ÿ(1.grp#1.timÿ-ÿ1.grp#0.tim)

        ÿ(ÿ1)ÿÿ1b.grp#0b.timÿ-ÿ1b.grp#1o.timÿ-ÿ2o.grp#0b.timÿ+ÿ2.grp#1.timÿ=ÿ0

        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿoutÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿ(1)ÿ|ÿÿ-.3333333ÿÿÿ2.180157ÿÿÿÿ-0.15ÿÿÿ0.883ÿÿÿÿ-5.667986ÿÿÿÿÿ5.00132
        ------------------------------------------------------------------------------

        .ÿlincomÿ(2.grp#2.timÿ-ÿ2.grp#0.tim)ÿ-ÿ(1.grp#2.timÿ-ÿ1.grp#0.tim)

        ÿ(ÿ1)ÿÿ1b.grp#0b.timÿ-ÿ1b.grp#2o.timÿ-ÿ2o.grp#0b.timÿ+ÿ2.grp#2.timÿ=ÿ0

        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿoutÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿ(1)ÿ|ÿÿÿÿÿÿÿÿÿ-3ÿÿÿ2.180157ÿÿÿÿ-1.38ÿÿÿ0.218ÿÿÿÿ-8.334653ÿÿÿÿ2.334653
        ------------------------------------------------------------------------------

        .

        Comment


        • #5
          Extract from the FAQ Advice:

          6. Why are real names preferred?

          You are asked to post on Statalist using your full real name, including given name(s) and a family name, such as "Ronald Fisher" or "Gertrude M. Cox". Giving full names is one of the ways in which we show respect for others and is a long tradition on Statalist. It is also much easier to get to know people when real names are used.

          If you overlook this on first registration, it is easy to fix. Click on “Contact us” located at the bottom right-hand corner of every page.


          Comment


          • #6
            I would like to add that it would be interesting to know your total N and the group N. If the number is quite low it might be better to simplify the models and maybe go with a paired permutation test. This would allow a design that is a bit different but still interesting and probably more robust since the ANOVA has some parametric requirements I suppose.
            Best wishes

            (Stata 16.1 MP)

            Comment

            Working...
            X