Announcement

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

  • Time weighted average

    Dear All,
    I have two groups- intervention and placebo group. Primary outcome is postoperative pain scores assessed with NRS scores during movement at five time points (2h, 6h, 12h, 24h, 48 h).
    I would like to calculate the time weighted average or area under the curve up to 48 hours.
    I tried in STATA but failed to do with proper command. Currently, I am using STATA version 15.1

    thank you in advance.
    Asish Subedi


    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(serialno group nrsmove0 nrsmove1 nrsmove2 nrsmove3 nrsmove4)
     1 1 2 3 7 5 3
     2 1 0 0 2 4 5
     3 2 4 6 4 5 3
     4 1 0 0 2 5 2
     5 2 2 2 3 4 7
     6 1 2 6 6 5 2
     7 2 0 3 4 4 3
     8 2 3 3 4 3 6
     9 1 1 1 1 4 2
    10 2 1 1 3 6 4
    end
    ------------------ copy up to and including the previous line ------------------


  • #2
    Asish:
    welcome to this forum.
    If NRS score is continuous, why not considering -xtreg- (presumably -re-, if your main interest is to detect potential differences in the NRS score between treated and controls):
    Code:
    input byte(serialno group nrsmove0 nrsmove1 nrsmove2 nrsmove3 nrsmove4)
     1 1 2 3 7 5 3
     2 1 0 0 2 4 5
     3 2 4 6 4 5 3
     4 1 0 0 2 5 2
     5 2 2 2 3 4 7
     6 1 2 6 6 5 2
     7 2 0 3 4 4 3
     8 2 3 3 4 3 6
     9 1 1 1 1 4 2
    10 2 1 1 3 6 4
    end
    reshape long nrsmove, i(serialno) j(wave)
    xtset serialno wave
    xtreg nrsmove i.group i.wave
    
    Random-effects GLS regression                   Number of obs     =         50
    Group variable: serialno                        Number of groups  =         10
    
    R-sq:                                           Obs per group:
         within  = 0.4047                                         min =          5
         between = 0.1489                                         avg =        5.0
         overall = 0.3424                                         max =          5
    
                                                    Wald chi2(5)      =      25.88
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0001
    
    ------------------------------------------------------------------------------
         nrsmove |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         2.group |        .72    .608605     1.18   0.237    -.4728438    1.912844
                 |
            wave |
              1  |          1   .6686637     1.50   0.135    -.3105567    2.310557
              2  |        2.1   .6686637     3.14   0.002     .7894433    3.410557
              3  |          3   .6686637     4.49   0.000     1.689443    4.310557
              4  |        2.2   .6686637     3.29   0.001     .8894433    3.510557
                 |
           _cons |       1.14    .603361     1.89   0.059    -.0425657    2.322566
    -------------+----------------------------------------------------------------
         sigma_u |  .69201798
         sigma_e |  1.4951774
             rho |  .17642243   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    .
    Another option that springs to my mind is repeated ANOVA; Joseph Coveney 's posts shows his comprehensive expertise on this topic (and on many others indeed).
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      I've done some work where NRS scores are the primary outcome measure, and it is conventional to summarize a period of observation by the area under the NRS score curve. So here's how that can be done:

      Code:
      //  GO LONG
      reshape long nrsmove, i(serialno) j(time_point)
      
      //  CREATE A VARIABLE THAT TRAPS ELAPSED TIME
      recode time_point (0 = 2) (1 = 6) (2 = 12) (3 = 24) (4 = 48), gen(elapsed_time)
      label var elapsed_time "Time (h)"
      label var time_point "Time Sequence [0-4]"
      
      //  CALCULATE AUC FOR EACH PATIENT
      by serialno (time_point), sort: integ nrsmove elapsed_time, gen(nrs_auc)
      by serialno (time_point): replace nrs_auc = nrs_auc[_N]
      label var nrs_auc "Area under NRS Curve (nrs h)"
      Added: The text of #1 asks about area under the curve, which is calculated above. The title of the thread, however, refers to time-weighted average. For the time-weighted average, just divide the area by 46 (= 48 - 2).

      Comment


      • #4
        Thank you Carlo Lazzaro and Clyde Schechter.
        I ran the code suggested by Clyde Schechter and found the following result.


        . ttest nrs_auc,by(group)

        Two-sample t test with equal variances
        ------------------------------------------------------------------------------
        Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
        ---------+--------------------------------------------------------------------
        1 | 25 172.3165 5.703263 28.51632 160.5456 184.0875
        2 | 25 190.5181 4.372053 21.86027 181.4946 199.5416
        ---------+--------------------------------------------------------------------
        combined | 50 181.4173 3.786466 26.77436 173.8081 189.0265
        ---------+--------------------------------------------------------------------
        diff | -18.20155 7.186241 -32.65045 -3.752641
        ------------------------------------------------------------------------------
        diff = mean(1) - mean(2) t = -2.5328
        Ho: diff = 0 degrees of freedom = 48

        Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
        Pr(T < t) = 0.0073 Pr(|T| > |t|) = 0.0146 Pr(T > t) = 0.9927

        I came across the literature where AUC was calculated using the trapezoid rule. My question is whether AUC calculation in STATA uses trapezoid rule by default or not. As suggested by Clyde Schechter for time-weighted average- do we need to divided by 46 for each calculated AUC ? If so, please explain me how did the value of 46 was obtained?
        regards,
        Asish Subedi

        Comment


        • #5
          No, the -integ- command does not use the trapezoid rule by default, it fits a cubic spline to the data points and integrates that. If you want it done by the trapezoid rule, specify the -trapezoid- option on the -integ- command.

          The average value is the area under the curve divided by the width of the base of the curve. Since your data runs from 2 hours to 48 hours, the width of that base is 46 hours.

          Comment


          • #6
            Thanks a lot.
            Asish Subedi

            Comment


            • #7
              Clyde Schechter,
              From the result, the mean ACU value for NRS scores over 48 hours in intervention is 172.31, while it is 190.51 in the placebo group. How are we going to interpret it in the result/discussion section ?
              Are they both the same- difference in time weighted average pain scores and summed pain intensity difference (SPID).

              Comment


              • #8
                From the result, the mean ACU value for NRS scores over 48 hours in intervention is 172.31, while it is 190.51 in the placebo group. How are we going to interpret it in the result/discussion section ?
                These means can't be interpreted in isolation. It is a different situation if this is observational data or a randomized trial. And, in either case, measures of uncertainty are required to clarify the situation. The means themselves are too incomplete an analysis to provide any useful interpretation.

                Difference in time weighted average and summed difference are not the same thing. For one thing, the SPID is not weighted, so this alone will make them different when the measurements are obtained at unequal time intervals.

                Comment


                • #9
                  Thanks a lot.
                  Asish Subedi

                  Comment

                  Working...
                  X