Announcement

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

  • Area under the curve for repeated measures anova

    Hello Everyone,

    I have been stuck at plotting area under the curve for a panel dataset (id) with six repeated measurements at three different conditions (just a difference in a month) for all same nine patients.
    I carried out the analysis by using repeated measures of ANOVA. However, my manager would like to see AUC for all three months.

    I used Pkexamin command but received an error "time variable takes on repeated values" (indeed it involves repeated measurements of time, with six readings)
    When I used pksumm command, it would not give me p-value (just .) but AUC of each category

    Secondly, in case I have AUC values for all three months, how would I be able to compare three AUCs (months) with a p-value

    Thanks

  • #2
    Try something like the following. Begin at the "Begin here" comment; the first part of the do-file just creates a fictitious dataset that has the same essential structure as yours for illustration.

    .ÿ
    .ÿversionÿ16.1

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿsetÿseedÿ`=strreverse("1551445")'

    .ÿquietlyÿsetÿobsÿ9

    .ÿ
    .ÿgenerateÿbyteÿpidÿ=ÿ_n

    .ÿgenerateÿdoubleÿpid_uÿ=ÿrnormal()

    .ÿ
    .ÿquietlyÿexpandÿ3ÿÿÿÿÿÿÿÿ

    .ÿbysortÿpid:ÿgenerateÿbyteÿcdnÿ=ÿ_n

    .ÿ
    .ÿquietlyÿexpandÿ6

    .ÿbysortÿpidÿcdn:ÿgenerateÿbyteÿtimÿ=ÿ_n

    .ÿ
    .ÿgenerateÿdoubleÿoutÿ=ÿpid_uÿ+ÿ10ÿ-ÿ(timÿ-ÿ3.5)^2ÿ+ÿrnormal()

    .ÿassertÿoutÿ>ÿ0

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿegenÿlongÿpid_cdnÿ=ÿgroup(pidÿcdn)

    .ÿ
    .ÿsetÿtypeÿdouble

    .ÿpkcollapseÿtimÿout,ÿid(pid_cdn)ÿstat(auc)ÿtrapezoidÿkeep(pidÿcdn)ÿnodots

    .ÿ
    .ÿxtregÿauc_outÿi.cdn,ÿi(pid)ÿfe

    Fixed-effectsÿ(within)ÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ27
    Groupÿvariable:ÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿÿÿ9

    R-sq:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
    ÿÿÿÿÿwithinÿÿ=ÿ0.1373ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ3
    ÿÿÿÿÿbetweenÿ=ÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ3.0
    ÿÿÿÿÿoverallÿ=ÿ0.0188ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ3

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(2,16)ÿÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ1.27
    corr(u_i,ÿXb)ÿÿ=ÿ0.0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.3067

    ------------------------------------------------------------------------------
    ÿÿÿÿÿauc_outÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿcdnÿ|
    ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.9303635ÿÿÿ.9332006ÿÿÿÿÿ1.00ÿÿÿ0.334ÿÿÿÿ-1.047933ÿÿÿÿÿ2.90866
    ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿÿ1.472431ÿÿÿ.9332006ÿÿÿÿÿ1.58ÿÿÿ0.134ÿÿÿÿ-.5058659ÿÿÿÿ3.450728
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ38.49384ÿÿÿ.6598725ÿÿÿÿ58.34ÿÿÿ0.000ÿÿÿÿÿ37.09497ÿÿÿÿ39.89271
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿsigma_uÿ|ÿÿ4.3739292
    ÿÿÿÿÿsigma_eÿ|ÿÿ1.9796174
    ÿÿÿÿÿÿÿÿÿrhoÿ|ÿÿ.82998434ÿÿÿ(fractionÿofÿvarianceÿdueÿtoÿu_i)
    ------------------------------------------------------------------------------
    Fÿtestÿthatÿallÿu_i=0:ÿF(8,ÿ16)ÿ=ÿ14.65ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿ0.0000

    .ÿtestparmÿi.cdn

    ÿ(ÿ1)ÿÿ2.cdnÿ=ÿ0
    ÿ(ÿ2)ÿÿ3.cdnÿ=ÿ0

    ÿÿÿÿÿÿÿF(ÿÿ2,ÿÿÿÿ16)ÿ=ÿÿÿÿ1.27
    ÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿÿÿÿ0.3067

    .ÿ
    .ÿ//ÿor
    .ÿ
    .ÿanovaÿauc_outÿcdnÿpid

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿÿ27ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.8821
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.97962ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.8084

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ469.13255ÿÿÿÿÿÿÿÿÿ10ÿÿÿ46.913255ÿÿÿÿÿ11.97ÿÿ0.0000
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcdnÿ|ÿÿ9.9823981ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ4.9911991ÿÿÿÿÿÿ1.27ÿÿ0.3067
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpidÿ|ÿÿ459.15016ÿÿÿÿÿÿÿÿÿÿ8ÿÿÿ57.393769ÿÿÿÿÿ14.65ÿÿ0.0000
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ62.702158ÿÿÿÿÿÿÿÿÿ16ÿÿÿ3.9188849ÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ531.83471ÿÿÿÿÿÿÿÿÿ26ÿÿÿ20.455181ÿÿ

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment


    • #3
      Hi Many many thanks for your response,

      Can you please indicate what these variables cdn, tim, out, pid refer to in your example. I started using stata just six months ago so I may have missed out in your post.

      Thanks

      Comment


      • #4
        Hello Mr Joseph,

        Thank you so much for your response, I figured out the comparison in your variables and how it applies to mine.

        Would you be able to tell me if I want to compare the section of AUC (1-30MIN) to AUC (30-60 MIN) within and between different categories of grouping variable?

        Thanks once again
        stay blessed

        Comment


        • #5
          Originally posted by Maria Majeed View Post
          Would you be able to tell me if I want to compare the section of AUC (1-30MIN) to AUC (30-60 MIN) within and between different categories of grouping variable?
          It's certainly doable, but it sounds like your manager is fishing. I would limit ad hoc analysis to graphical exploration and would restrict hypothesis testing to that which is driven by the research question in advance.

          Comment

          Working...
          X