I am trying to figure out how to calculate Area Under Curve or AUC of a time series composed by one "time" variable in POSIXct format, and another numerical variable (RQ in my case). What I want to do, in the end, is to compare the AUC of the variable RQ between males and females (I am working with mice). For that, I need the AUC value and the error/deviation of the AUC. I previously plotted the data and it looks like this:
.
There I ploted WT vs TG, but is the same as Females and males. The shadowed areas correspond to dark hours (that is, during the night).
I grouped the data for each individual mice to see if I have differences, and I saw none, but I would try to compare the AUCs, because when I do the group by Mice, I have more info for each individual, but I lose a lot of info of the general behavior of the RQ variable.
The data frame looks like this:
My variables are:
- Mice (the identification code for each mice, categorical variable)
- Absolute_time (variable time in POSIXct format, goes from 2021-04-28 15:29:42 to 2021-04-30 11:01:42 and I have info for all mice every minute)
- RQ (numerical variable I want to test)
- Sex (categorical variable I want to test, 2 levels: female and male)
If you think about any other way two compare 2 curves, I am also interested to hear your ideas.