Hi everyone,
I would need some help with calculating the area under the curve. In my study patients' heart rate was measured at different time points throughout an operation (at the start of the operation, after 1 minute, 5 minutes, 10 minutes, etc.). For my analysis, I would need to calculate the area under the curve before comparing different groups of patients who received different treatments.
My problem is: some patients only have data for the first 2 or 3 time points as it was a short operation, while others have data for all 5 time points as it was a rather long operation.
If I now calculate the area under the curve in spss using the syntax below, I obtain a very large area under the curve for patients who had a long operation, while a rather small area is obtained for patients who only have data for the first time points. I believe it is not correct to compare this data as this has nothing to do with the treatment they received/the group they belonged to, but rather with the length of their operation, right? Is their any way to take into account the number of time points when calculating the area under the curve?
This is the syntax I've been using:
Thank you so much in advance!
SORT CASES BY ID.
CASESTOVARS
/ID=ID
/GROUPBY=VARIABLE.
VECTOR time = T0 to T3.
VECTOR SAT = T0spo2 to T3spo2.
COMPUTE cmax = MAX(T0spo2 to T3spo2).
COMPUTE tmax = $sysmis.
COMPUTE lagSAT = $sysmis.
COMPUTE lagtime = $sysmis.
COMPUTE auc = 0.
LOOP #k = 1 to 3.
DO IF (NOT(MISSING(SAT(#k)))).
IF (NOT(MISSING(lagSAT)))
auc = auc + (time(#k) - lagtime)*(lagSAT + SAT(#k))/2 .
IF (SAT(#k) = cmax and missing(tmax)) tmax = time(#k) .
COMPUTE lagSAT = SAT(#k).
COMPUTE lagtime = time(#k).
END IF.
END LOOP.
EXECUTE.