I would like to calculate an area under the curve with respect to ground (AUCg) according to this formula in this paper (Pruessner, Kirschbaum, Meinlschmid & Hellhammer, 2003). I have three measurement time points (1,2,3) with time intervals of 65 and 45 min for about 200 persons. My code so far looks something like this, but I would like to have an auc value for each person to do some further analysis with that.
df$auc <- sum((df$hor_2 + df$hor_1)/2*65 + (df$hor_3 + df$hor_2)/2*45 , na.rm = TRUE)
df = dataframe
However, this only results in one value and not a value for each person. Someone knows how to exactly calculate this? I found some codes in the internet, however there are not for auc with respect to the ground and not for calculating for each person. Any help is really appreciated.
Literature: Pruessner, J. C., Kirschbaum, C., Meinlschmid, G., & Hellhammer, D. H. (2003). Two formulas for computation of the area under the curve represent measures of total hormone concentration versus time-dependent change. Psychoneuroendocrinology, 28(7), 916-931.