time_calc: Create time variables for usage in NONMEM analyses
Description
This function calculates the most important time variables based on multiple variables in
a data frame.
Usage
time_calc(
data,
datetime,
evid = NULL,
addl = NULL,
ii = NULL,
amt = "AMT",
id = "ID",
dig = 2
)
Value
a data frame with the calculated times
Arguments
data
data frame to perform the calculations on
datetime
character identifying the date/time variable (POSIXct) within the data frame
evid
character identifying the event ID (EVID) within the data frame
addl
character identifying the additional dose levels (ADDL) within the data frame
ii
character identifying the interdose interval (II) within the data frame
amt
character identifying the amount variable (only needed if evid is not provided)
id
character identifying the ID or subject variable
dig
numeric indicating with how many digits the resulting times should be available
Author
Richard Hooijmaijers
Details
The function calculates the TIME, TALD (time after last dose) and TAFD (time after first dose).
The different time variables are calculated in hours, where a POSIXct for the datetime variable is expected.
The function takes into account ADDL and II records when provided, to correctly identify the TALD.
One must be cautious however when having ADDL/II and a complex dosing schedule (e.g. alternating dose schedules,
more than 1 dose per day, multiple compounds administration). In general it is good practice to double check the
output for multiple subjects in case of complex designs including ADDL/II.