This function calculates the last dose amount (LDOS), the time after
last dose (TAD), time after first dose (TAFD), and observation
occasion (OCC). Use lastdose()
to add (or potentially replace) columns to the input data frame;
lastdose_list() and lastdose_df() returns calculated information
as either list or data.frame format without modifying the input data.
Usage
lastdose(
data,
...,
include_ldos = TRUE,
include_tafd = getOption("lastdose.include_tafd", FALSE),
include_occ = getOption("lastdose.include_occ", TRUE)
)
lastdose_list(
data,
time_col = find_time_col(data),
time_units = getOption("lastdose.time_units", NULL),
id_col = find_id_col(data),
fill = -99,
back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
comments = find_comments(data),
include_occ = getOption("lastdose.include_occ", TRUE)
)
lastdose_df(data, ...)Arguments
- data
data set as data frame; see
details- ...
arguments passed to
lastdose_list()- include_ldos
logical; ifFALSEthen theLDOSdata is not appended to the data set. Only used for thelastdose()function.- include_tafd
logical; ifFALSE, then time after first dose (TAFD) data is not appended to the data set; this is only used for thelastdose()function.- include_occ
logical; ifFALSEthen observation occasion counter (OCC; see Details) is not appended to the data set.- time_col
character name for the
TIMEcolumn; this could be time after first dose or time after first record or time relative to any origin; input may benumericorPOSIXct(e.g.DATETIME); ifPOSIXct, a numeric value will be calculated based on the value oftime_units. The data frame will be searched for the first matching candidate time column usingfind_time_col(); if you don't wantlastdoseto search, you should pass in the name of the column to use forTIME.- time_units
for calculating time when the time column inherits
POSIXct; you may use any value that is valid fordifftime()- id_col
character name for the subject
IDcolumn; may be numeric or character; if character, a numeric value is derived. The data frame will be searched for the first matching candidateIDcolumn usingfind_id_col(); if you don't wantlastdoseto search, you should pass in the name of the column to use forID.- fill
the value for
TADandTAFDthat is used for records when no doses are found for an individual or whenback_calcisFALSE.- back_calc
if
TRUE, then the time before the first dose is calculated for records prior to the first dosing record when at least one dosing record is found in the data set. Records before the first dosing record will have negative values.- addl_ties
what to do when doses scheduled through
ADDLhappen at the same time as observation records; ifobs_firstthen the observation is assumed to happen before the dose and the observation is a trough concentration; ifdose_firstthen the dose is assumed to be administered and the observation made immediately after (with no advance in time). See details.- comments
a logical vector with length equal to the number of rows in
dataindicating which records are to be ignored when looking forTADandLDOS.
Details
When calling lastdose() to modify the data frame, two columns will be
added (by default): TAD indicating the time after the most-recent dose,
and LDOS indicating the amount of the most recent dose. TAFD indicating
the time after the first dose record (EVID 1 or 4) can be added via the
include_tafd argument and users can opt out from adding LDOS with the
include_ldos argument.
When calling lastdose_list() or lastdose_df(), the respective items are
accessible with tad, tafd, and ldos (note the lower case form here to
distinguish from the columns that might be added to the data frame).
Time after first dose (TAFD): note that time after first dose (TAFD)
is the time after the first dosing record (EVID 1 or 4) in the data frame
that you pass in. If you don't have a dosing record for the first dose to
anchor this calculation, you should opt out.
Occasion (OCC): observation occasions (OCC) occur when there is an
observation record (with EVID=0) following a dose record (EVID 1 or 4);
OCC starts at 0 and increments with each dose that is followed by at
least one observation record. The OCC calculation ignores all commented
records (doses or observations).
Handling of commented records: Dosing records that have been "commented"
(as indicated with the comments argument) will never be considered as
actual doses when determining TAD, TAFD, and LDOS. But commented
records (doses and non-doses) will be assigned TAD, TAFD, and LDOS
according to the last non-commented dosing record.
Additional notes:
All functions require an input data set as a data frame
The data set should be formatted according to
NMTRANtype conventionsRequired columns
A subject ID column (either
IDor user-specified)A record time column (either
TIMEor user-specified)AMToramt: dose amount for dosing recordsEVIDorevid: event ID; records withEVIDor 1 or 4 are considered dosing records
Optional columns
ADDLoraddl: additional doses to administerIIorii: dosing interval
An error is generated if required columns are not found; no error or warning if optional columns are not found
All required and optional columns are required to be numeric
Missing values are not allowed in:
ID,EVID,ADDL,IIWhen missing values are found in
TIME, bothTADandLDOSare set to missingAn error is generated for missing
AMTin dosing records (evid 1 or 4)No error is generated for missing
AMTin non-dosing records
An example illustrating the addl_ties argument: when there is Q24h
dosing and both an an additional dose and an observation happen at 24 hours,
obs_first will set the observation TAD to 24 and dose_first will set
the observation TAD to 0.
Options
These are options that can be set to customize lastdose behavior
for the current context. See ?options for how to set an option.
lastdose.time_units: sets the default time unit that is used to calculate relative times when the time column is represented as date-time data (POSIXct)lastdose.id_col: sets the default value for theid_colargument to last dose; this identifies the column that is to be used to distinguish individuals; the data in this column may be numeric or characterlastdose.include_tafd: sets default value forinclude_tafd; ifTRUEthen the time since the first dose record (EVID 1 or EVID 4) in the data set will be automatically appended to the output data frame when callinglastdose();tafdis always included when callinglastdose_df()andlastdose_list()
Examples
file <- system.file("csv/data1.csv", package="lastdose")
require("Rcpp")
#> Loading required package: Rcpp
data <- read.csv(file)
a <- lastdose(data)
b <- lastdose_df(data)
c <- lastdose_list(data)
