trapRule | R Documentation |
Given a data.frame of concentration-time data, trapRule
calculates the
area under the concentration-time curve for the times included in the input
data.frame using either the linear or the linear up/log down trapezoidal
rule. This does NOT extrapolate to infinity or back extrapolate to t0; it
only calculates the area under the curve for the time points included.
If you supply a data.frame with multiple individuals, this will assume you
want to calculate the mean AUC and will still only return a single number. If
you want one AUC per subject, please see the examples at the bottom of the
help file.
trapRule(
ct_dataframe,
concentration = Concentration,
time = Time,
type = "LULD"
)
ct_dataframe |
input data.frame with concentration-time data. |
concentration |
the name of the column containing drug concentrations (unquoted) |
time |
the name of the column containing time data (unquoted) |
type |
the type of trapezoidal rule to use. Options are "LULD" (default) for "linear up, log down" or "linear". |
A few notes:
If there are two consecutive time points with the same measured concentration, that results in an undefined value for the log trapezoidal rule. To deal with this, anytime the user has opted for the linear up/log down trapezoidal rule but there are also consecutive time points with the same concentration, those individual trapezoids will be calculated linearly rather than using a log function and all AUCs will be added together at the end.
The option of using cubic splines for calculating the AUC was intentionally omitted because they can become unstable with noisy concentration-time data and are thus less desirable than the trapezoidal rule. For more details, please see https://www.certara.com/2011/04/02/calculating-auc-linear-and-log-linear/.
Returns the calculated AUC
MDZmean <- MDZct %>% filter(Trial == "mean" & File == "mdz-5mg-sd-fa1.xlsx")
trapRule(MDZmean, concentration = Conc, time = Time)
trapRule(MDZmean, concentration = Conc, time = Time, type = "linear")
# Get the AUC for each combination of individual and trial
MDZct %>% filter(File == "mdz-5mg-sd-fa1.xlsx" &
DoseNum == 1) %>%
group_by(Individual, Trial) %>%
group_modify(~ .x %>% summarize(
AUC = trapRule(.x,
concentration = Conc,
time = Time,
type = "LULD")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.