Announcement

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

  • incremental area under the curve

    Dear team,

    I am trying to compare the area under the curve of blood glucose results after the meal. The samples are taken at 0, 30 min, 60 min, 90 min and 120 minutes.

    what is the formula to generate the area under the curve above the baseline (The incremental area under the curve).

    Is it possible using Stata command?

    Thank you.

  • #2
    Yes. You need to have the data in long layout, that is each patient has 5 observations in the data set, one each for times 0, 30, 60, 90, and 120 minutes. Let's say the patient is identified by the variable id, and time since the meal is in a variable called time. The glucose measurements are in a variable called glucose. Then you use the -integ- command Here's an example with some made up (and rather unrealistic) data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int id float time int glucose
     1   0 255
     1  30 218
     1  60 160
     1  90  69
     1 120 150
     2   0  67
     2  30 205
     3   0  92
     3  30 164
     3  60 124
     3  90 155
     4   0 181
     4  30 170
     4  60 163
     4  90 148
     4 120 128
     5   0 138
     5  30 121
     5  60 117
     5  90 136
     5 120 123
     6   0 293
     6  30 315
     6  60 363
     6  90 308
     6 120 225
     7   0 199
     7  30 176
     7  60 135
     7  90 224
     8   0 288
     8  30 208
     8  60  99
     8  90  34
     8 120 152
     9   0  85
     9  30  75
     9  60  84
     9  90  84
     9 120  93
    10   0  96
    10  30  88
    end
    
    //    TO CALCULATE COMPLETE GLUCOSE AUC
    integ glucose time, by(id) gen(total_auc)
    by id (time), sort: replace total_auc = total_auc[_N]
    
    //    TO CALCULATE AUC FOR INCREMENT ABOVE BASELINE GLUCOSE
    by id (time), sort: gen delta_glucose = glucose - glucose[1]
    integ delta_glucose time, by(id) gen(incr_auc)
    by id (time), sort: replace incr_auc = incr_auc[_N]

    Comment


    • #3
      Thank you so much dear Clyde.

      I used the commands above after arranging my data the way you showed.

      I managed to calculate the total and incremental area under the curve but I found some differences when I tried to validate my answers with the trapezoidal rule.

      the delta_glucose that you calculate, does it take into account the entire baseline area under the curve?

      For example: 0 85
      30 140
      60 137
      120 120
      by above commands: AUC= 15479.849
      incr_AUC=5279.849
      But with trapezoidal rule: I found:
      AUC=15240
      incr_AUC=5040

      Can you try to help me understand these differences?

      Thanks
      Jean

      Comment


      • #4
        -integ- by default fits cubic splines when calculating integrals, rather than using the trapezoidal rule. If you want it to use the trapezoidal rule instead, you can get that with the -trapezoid- option. If you do that, the results will match what you calculated. Do read -help integ-.

        The trapezoidal rule gives exact results when the function you are trying to integrate is linear or quadratic. But a glucose tolerance curve will not be one of those. It will have a different shape that is probably better approximated with cubic splines. So I would suggest sticking with -integ-'s default here.

        I do not understand your question about delta_glucose. By differencing each glucose measurement from the time 0 (i.e. baseline) glucose, you remove from the integration everything below that level, yes. Why do you think it might be otherwise?

        Comment


        • #5
          I have a similar problem, but with five different diets. How can I calculate the incremental area under the curve for each diet for each person ? Your help will be greatly appreciated. I have attached sample data

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input byte(id diet) int time float glucose
          1 1   0  5.222222
          1 1  15  8.444445
          1 1  30  8.944445
          1 1  45  7.944445
          1 1  60  8.555555
          1 1  90         6
          1 1 120       5.5
          1 2   0         5
          1 2  15  5.777778
          1 2  30  7.333333
          1 2  45  5.944445
          1 2  60       5.5
          1 2  90  6.055555
          1 2 120  5.444445
          1 3   0         5
          1 3  15  6.055555
          1 3  30  7.055555
          1 3  45  6.833333
          1 3  60  6.833333
          1 3  90         6
          1 3 120         5
          1 4   0  4.777778
          1 4  15         6
          1 4  30  4.944445
          1 4  45  5.888889
          1 4  60  5.388889
          1 4  90       4.5
          1 4 120 4.4444447
          1 5   0 4.4444447
          1 5  15 4.6666665
          1 5  30  5.611111
          1 5  45  5.666667
          1 5  60         5
          1 5  90  5.166667
          1 5 120  4.888889
          2 1   0  4.888889
          2 1  15  7.222222
          2 1  30  7.277778
          2 1  45  6.444445
          2 1  60  5.833333
          2 1  90  5.333333
          2 1 120  4.833333
          2 2   0 4.7222223
          2 2  15  4.944445
          2 2  30  5.833333
          2 2  45  5.722222
          2 2  60 4.7222223
          2 2  90  4.833333
          2 2 120         5
          2 3   0 4.4444447
          2 3  15  4.888889
          2 3  30  5.777778
          2 3  45  5.666667
          2 3  60 4.4444447
          2 3  90  5.888889
          2 3 120  5.111111
          2 4   0  3.166667
          2 4  15       5.5
          2 4  30         6
          2 4  45  5.722222
          2 4  60       5.5
          2 4  90  5.222222
          2 4 120  5.111111
          2 5   0 4.6666665
          2 5  15  4.888889
          2 5  30 4.6666665
          2 5  45         5
          2 5  60  4.777778
          2 5  90         5
          2 5 120 4.6666665
          3 1   0  5.222222
          3 1  15  7.555555
          3 1  30       9.5
          3 1  45 11.333333
          3 1  60 10.944445
          3 1  90  9.555555
          3 1 120  8.222222
          3 2   0  5.833333
          3 2  15  5.555555
          3 2  30  6.222222
          3 2  45  6.277778
          3 2  60  6.111111
          3 2  90  5.555555
          3 2 120  4.833333
          3 3   0  5.277778
          3 3  15  5.611111
          3 3  30  6.777778
          3 3  45       6.5
          3 3  60  6.944445
          3 3  90  5.888889
          3 3 120  5.555555
          3 4   0  5.888889
          3 4  15  5.722222
          3 4  30  5.944445
          3 4  45         6
          3 4  60 4.5555553
          3 4  90  5.055555
          3 4 120  5.111111
          3 5   0       5.5
          3 5  15  5.333333
          end

          Comment


          • #6
            I don't know what you mean by the "incremental" area under the curve. If you want, in each observation, the area under the curve from time 0 for that person and that diet, up to that point in time:
            Code:
            by id diet (time), sort: integ glucose time, gen(auc)

            Comment


            • #7
              Thank you very much. It worked perfectly.

              Comment

              Working...
              X