Incremental Area Under the Curve

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Incremental Area Under the Curve

njdempster
Hi, I would like to calculate the incremental area under the curve (for
example area above fasting glucose value, excluding negative areas (glucose
value is less than fasting glucose value) after study participants eat a
standardised meal).

I found this syntax for an example data set:



* Next sample data come from the above web site.
DATA LIST LIST /id meas0 meas15 meas30 meas45 meas60 meas90 meas120 iauc1
(9F8.1).
BEGIN DATA
0 4.3 6.3 7.9 5.3 4.1 4.6 4.9 114
1 4 6 6.7 5.5 5.3 5 4.2 155
2 4.1 5.8 8 6.5 5.9 4.8 3.9 179
3 4 5 5.8 5.4 4.8 4.2 4.4 93
4 4.1 6.3 9 8.7 6.7 5.7 3.9 279
5 5 7.1 8.8 8 5.6 5.4 4.2 155
END DATA.
LIST.

* Set the time constants for the horizontal axis.
DO REPEAT h = h0 h15 h30 h45 h60 h90 h120
/ t = 0 15 30 45 60 90 120.
COMPUTE h = t.
END REPEAT.
EXECUTE.


* trapezoidal integration of glusose = f(time) curve .
VECTOR time = h0 to h120.
VECTOR gluc = meas0 to meas120 .
COMPUTE iauc2 = 0.
LOOP #k = 2 to 7.
IF #k=2 inival = gluc(1).
DO IF (NOT(MISSING(gluc(#k)))).
COMPUTE minval=MIN(gluc(#k-1),gluc(#k)) - inival.
COMPUTE maxval=MAX(gluc(#k-1),gluc(#k)) - inival.
DO IF minval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*((gluc(#k -1) +
gluc(#k))/2-inival) .
ELSE IF maxval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*(maxval / (maxval -
minval)*maxval/2) .
END IF.
END IF.
END LOOP.

* Clean up.
MATCH FILES FILE=* /DROP=h0 h15 h30 h45 h60 h90 h120 minval maxval inival.
EXECUTE.

I get this output:

<http://spssx-discussion.1045642.n5.nabble.com/file/t341454/Screen_Shot_2018-05-30_at_21.png>

but it doesn't appear to be calculating anything. Slightly confusingly, the
iauc that we would want to calculate in the above example looks like it is
actually typed in as part of the syntax rather than calculated.

I'd be grateful for any advice on how to get this working and also how to
modify the syntax for my own study (11 time points as pasted in below
example):

t(min) glucose value
0 4.746
15 6.688
30 7.053
45 6.953
60 5.483
90 4.654
120 4.532
180 4.455
240 4.393
300 4.295

BW,

Niall
360 4.621



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Incremental Area Under the Curve

Rich Ulrich

The syntax could use some more commenting, but it looks good to me.


What is listed does NOT show the "LIST" command that lists the original

data, which includes iauc1.  What is listed does NOT request that anything

more be listed out - which would include iauc2 that has been calculated by

the syntax.


Maybe the job ran just fine, and just need to do something to look at the

results - What does the data editor show for data?


As to adapting ... If you don't understand the syntax, you are undertaking

something hazardous to correct analyses. Here's an important aspect to understand -


VECTOR time = h0 to h120.
VECTOR gluc = meas0 to meas120 .


   - The lines here, VECTOR, define what is to be used in the loop lower, as indexed

variables, time( )   and  gluc( ) .     The time( ) variables are defined in the DO REPEAT

as the sampling times.    You need to define your  ho ... h369 ... according to your design. 

The gluc( ) variables are the glucose data which were read in as meas0 ... meas120.

You need to put your glucose variables into the VECTOR.


--

Rich Ulrich





From: SPSSX(r) Discussion <[hidden email]> on behalf of njdempster <[hidden email]>
Sent: Wednesday, May 30, 2018 4:49:37 PM
To: [hidden email]
Subject: Incremental Area Under the Curve
 
Hi, I would like to calculate the incremental area under the curve (for
example area above fasting glucose value, excluding negative areas (glucose
value is less than fasting glucose value) after study participants eat a
standardised meal).

I found this syntax for an example data set:



* Next sample data come from the above web site.
DATA LIST LIST /id meas0 meas15 meas30 meas45 meas60 meas90 meas120 iauc1
(9F8.1).
BEGIN DATA
0       4.3 6.3 7.9 5.3 4.1 4.6 4.9 114
1       4 6 6.7 5.5 5.3 5 4.2 155
2       4.1 5.8 8 6.5 5.9 4.8 3.9 179
3       4 5 5.8 5.4 4.8 4.2 4.4 93
4       4.1 6.3 9 8.7 6.7 5.7 3.9 279
5       5 7.1 8.8 8 5.6 5.4 4.2 155
END DATA.
LIST.

* Set the time constants for the horizontal axis.
DO REPEAT h = h0 h15 h30 h45 h60 h90 h120
/ t = 0 15 30 45 60 90 120.
COMPUTE h = t.
END REPEAT.
EXECUTE.


* trapezoidal integration of glusose = f(time) curve .
VECTOR time = h0 to h120.
VECTOR gluc = meas0 to meas120 .
COMPUTE iauc2 = 0.
LOOP #k = 2 to 7.
IF #k=2 inival = gluc(1).
DO IF (NOT(MISSING(gluc(#k)))).
COMPUTE minval=MIN(gluc(#k-1),gluc(#k)) - inival.
COMPUTE maxval=MAX(gluc(#k-1),gluc(#k)) - inival.
DO IF minval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*((gluc(#k -1) +
gluc(#k))/2-inival) .
ELSE IF maxval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*(maxval / (maxval -
minval)*maxval/2) .
END IF.
END IF.
END LOOP.

* Clean up.
MATCH FILES FILE=* /DROP=h0 h15 h30 h45 h60 h90 h120 minval maxval inival.
EXECUTE.

I get this output:

<http://spssx-discussion.1045642.n5.nabble.com/file/t341454/Screen_Shot_2018-05-30_at_21.png>

but it doesn't appear to be calculating anything. Slightly confusingly, the
iauc that we would want to calculate in the above example looks like it is
actually typed in as part of the syntax rather than calculated.

I'd be grateful for any advice on how to get this working and also how to
modify the syntax for my own study (11 time points as pasted in below
example):

t(min) glucose value
0       4.746
15      6.688
30      7.053
45      6.953
60      5.483
90      4.654
120     4.532
180     4.455
240     4.393
300     4.295

BW,

Niall
360     4.621



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Incremental Area Under the Curve

David Marso
Administrator
In reply to this post by njdempster
"I'd be grateful for any advice on how to get this working and also how to
modify the syntax for my own study (11 time points as pasted in below
example): "

It appears to work just fine.  Your output in question is generated prior to
ANY data transformations!!
I suspect your best bet for adapting for your own study is to either make
the data wide using CASESTOVARS or rewrite it using LAG and SCRATCH
variables. Pay attention and study what Ray's code is doing.



njdempster wrote

> Hi, I would like to calculate the incremental area under the curve (for
> example area above fasting glucose value, excluding negative areas
> (glucose
> value is less than fasting glucose value) after study participants eat a
> standardised meal).
>
> I found this syntax for an example data set:
>
>
>
> * Next sample data come from the above web site.
> DATA LIST LIST /id meas0 meas15 meas30 meas45 meas60 meas90 meas120 iauc1
> (9F8.1).
> BEGIN DATA
> 0 4.3 6.3 7.9 5.3 4.1 4.6 4.9 114
> 1 4 6 6.7 5.5 5.3 5 4.2 155
> 2 4.1 5.8 8 6.5 5.9 4.8 3.9 179
> 3 4 5 5.8 5.4 4.8 4.2 4.4 93
> 4 4.1 6.3 9 8.7 6.7 5.7 3.9 279
> 5 5 7.1 8.8 8 5.6 5.4 4.2 155
> END DATA.
> LIST.
>
> * Set the time constants for the horizontal axis.
> DO REPEAT h = h0 h15 h30 h45 h60 h90 h120
> / t = 0 15 30 45 60 90 120.
> COMPUTE h = t.
> END REPEAT.
> EXECUTE.
>
>
> * trapezoidal integration of glusose = f(time) curve .
> VECTOR time = h0 to h120.
> VECTOR gluc = meas0 to meas120 .
> COMPUTE iauc2 = 0.
> LOOP #k = 2 to 7.
> IF #k=2 inival = gluc(1).
> DO IF (NOT(MISSING(gluc(#k)))).
> COMPUTE minval=MIN(gluc(#k-1),gluc(#k)) - inival.
> COMPUTE maxval=MAX(gluc(#k-1),gluc(#k)) - inival.
> DO IF minval>0.
> COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*((gluc(#k -1) +
> gluc(#k))/2-inival) .
> ELSE IF maxval>0.
> COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*(maxval / (maxval -
> minval)*maxval/2) .
> END IF.
> END IF.
> END LOOP.
>
> * Clean up.
> MATCH FILES FILE=* /DROP=h0 h15 h30 h45 h60 h90 h120 minval maxval inival.
> EXECUTE.
>
> I get this output:
>
> &lt;http://spssx-discussion.1045642.n5.nabble.com/file/t341454/Screen_Shot_2018-05-30_at_21.png&gt; 
>
> but it doesn't appear to be calculating anything. Slightly confusingly,
> the
> iauc that we would want to calculate in the above example looks like it is
> actually typed in as part of the syntax rather than calculated.
>
> I'd be grateful for any advice on how to get this working and also how to
> modify the syntax for my own study (11 time points as pasted in below
> example):
>
> t(min) glucose value
> 0 4.746
> 15 6.688
> 30 7.053
> 45 6.953
> 60 5.483
> 90 4.654
> 120 4.532
> 180 4.455
> 240 4.393
> 300 4.295
>
> BW,
>
> Niall
> 360 4.621
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Incremental Area Under the Curve

Rich Ulrich
In reply to this post by njdempster

Here is a version of the example that is easier to parse. I have only

changed the variable names and added comments.



* Next sample data come from the above web site.
DATA LIST LIST /id gluc0 gluc15 gluc30 gluc45 gluc60 gluc90 gluc120 iauc1

(9F8.1).
BEGIN DATA
0       4.3 6.3 7.9 5.3 4.1 4.6 4.9 114
1       4 6 6.7 5.5 5.3 5 4.2 155
2       4.1 5.8 8 6.5 5.9 4.8 3.9 179
3       4 5 5.8 5.4 4.8 4.2 4.4 93
4       4.1 6.3 9 8.7 6.7 5.7 3.9 279
5       5 7.1 8.8 8 5.6 5.4 4.2 155
END DATA.
LIST.

* Set the time constants for the horizontal axis.

DO REPEAT timvec = t0 t15 t30 t45 t60 t90 t120

/ t = 0 15 30 45 60 90 120.

COMPUTE timvec = t.

END REPEAT.

EXECUTE.


* trapezoidal integration of glucose = f(time) curve .

*vector items will be referred to as (1) through (7). 

VECTOR time = t0 to t120.

VECTOR gluc = gluc0 to gluc120 .

*initialize total; increment is (average of coordinates)*(width in minutes).

COMPUTE iauc2 = 0.

LOOP #k = 2 to 7.

IF #k=2 inival = gluc(1).

DO IF (NOT(MISSING(gluc(#k)))).

COMPUTE minval=MIN(gluc(#k-1),gluc(#k)) - inival.

COMPUTE maxval=MAX(gluc(#k-1),gluc(#k)) - inival.

*increment when both values are positive.

DO IF minval>0.

COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*((gluc(#k -1) + gluc(#k))/2-inival) .

*increment when time has to be shortened because Max > 0, Min < 0.

ELSE IF maxval>0.

*note that the final "maxval/2" is the average gluc added for the shortened interval.

*I've moved the final parenthesis to make that clearer.

COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*(maxval / (maxval -minval))*maxval/2 .

END IF.

END IF.

END LOOP.

* Clean up.

MATCH FILES FILE=* /DROP=h0 h15 h30 h45 h60 h90 h120 minval maxval inival.

EXECUTE.



From: SPSSX(r) Discussion <[hidden email]> on behalf of njdempster <[hidden email]>
Sent: Wednesday, May 30, 2018 4:49:37 PM
To: [hidden email]
Subject: Incremental Area Under the Curve
 
Hi, I would like to calculate the incremental area under the curve (for
example area above fasting glucose value, excluding negative areas (glucose
value is less than fasting glucose value) after study participants eat a
standardised meal).

I found this syntax for an example data set:



* Next sample data come from the above web site.
DATA LIST LIST /id meas0 meas15 meas30 meas45 meas60 meas90 meas120 iauc1
(9F8.1).
BEGIN DATA
0       4.3 6.3 7.9 5.3 4.1 4.6 4.9 114
1       4 6 6.7 5.5 5.3 5 4.2 155
2       4.1 5.8 8 6.5 5.9 4.8 3.9 179
3       4 5 5.8 5.4 4.8 4.2 4.4 93
4       4.1 6.3 9 8.7 6.7 5.7 3.9 279
5       5 7.1 8.8 8 5.6 5.4 4.2 155
END DATA.
LIST.

* Set the time constants for the horizontal axis.
DO REPEAT h = h0 h15 h30 h45 h60 h90 h120
/ t = 0 15 30 45 60 90 120.
COMPUTE h = t.
END REPEAT.
EXECUTE.


* trapezoidal integration of glusose = f(time) curve .
VECTOR time = h0 to h120.
VECTOR gluc = meas0 to meas120 .
COMPUTE iauc2 = 0.
LOOP #k = 2 to 7.
IF #k=2 inival = gluc(1).
DO IF (NOT(MISSING(gluc(#k)))).
COMPUTE minval=MIN(gluc(#k-1),gluc(#k)) - inival.
COMPUTE maxval=MAX(gluc(#k-1),gluc(#k)) - inival.
DO IF minval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*((gluc(#k -1) +
gluc(#k))/2-inival) .
ELSE IF maxval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*(maxval / (maxval -
minval)*maxval/2) .
END IF.
END IF.
END LOOP.

* Clean up.
MATCH FILES FILE=* /DROP=h0 h15 h30 h45 h60 h90 h120 minval maxval inival.
EXECUTE.

I get this output:

<http://spssx-discussion.1045642.n5.nabble.com/file/t341454/Screen_Shot_2018-05-30_at_21.png>

but it doesn't appear to be calculating anything. Slightly confusingly, the
iauc that we would want to calculate in the above example looks like it is
actually typed in as part of the syntax rather than calculated.

I'd be grateful for any advice on how to get this working and also how to
modify the syntax for my own study (11 time points as pasted in below
example):

t(min) glucose value
0       4.746
15      6.688
30      7.053
45      6.953
60      5.483
90      4.654
120     4.532
180     4.455
240     4.393
300     4.295

BW,

Niall
360     4.621



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD