blk.tad: Compute Time After Dose

View source: R/PCSmisc.R

blk.tadR Documentation

Compute Time After Dose

Description

These functions compute the time after dose (TAD) for a PK data set in block-format.

Usage

blk.tad(time, id, dose.ind, na.action = c("neg.time", "fill"), fill = NA, diff.op = difftime.default)

blk.tad2(time, id, dose.t, id2, na.action = c("neg.time", "fill"), fill = NA, diff.op = difftime.default)

Arguments

time

A vector of event times in block-format with respect to id.

id,id2

A valid block-format ID.

dose.ind

A logical vector in block-format with respect to id. Indicates rows corresponding to dose events.

dose.t

A vector of dose times in block-format with respect to id2.

na.action

How to handle events prior to the first dose. See details.

fill

A value to use when no other value is appropriate.

diff.op

A function that subtracts one time from another.

Details

These functions compute the TAD, the difference between the time of a PK observation and the time of the dosing event that most nearly precedes it.

There are two variants. In the first variant, all event times are in a single vector and an indicator is used to distiguish between dose events and observation events. In the second variant, dose times and observation times are in separate vectors, each with an associated block-format ID vector. In the case where a dose time and observation time match exactly, in the first variant events occur in the order specified, while in the second variant it is always assumed that the observation comes first (i.e. observations precede doses at the same time).

There are two ways of handling observations that occurs before the first dose. If na.action == "neg.time" (the default), then the TAD values for these observations are negative, and their magnitudes are the time until the first dose. If na.action == "fill" then the value of fill is used to ‘fill in’ the TAD for all such observations.

Value

A numeric vector of TAD values in block-format with respect to id.

Author(s)

Benjamin Rich <mail@benjaminrich.net>

See Also

tapply difftime

Examples

require(nlme)
data(Phenobarb)
dat <- Phenobarb[1:56,]  # First 4 subjects
attach(dat)

cbind(dat, TAD=blk.tad(time, asID(Subject), !is.na(dose)))

detach(dat)

id <- gl(4, 6)
id2 <- gl(4, 2)
time <- rep(c(0, 1, 6, 12, 18, 24), 4)
dose.t <- rep(c(0, 12), 4)
data.frame(id=id, time=time, tad=blk.tad2(time, id, dose.t, id2))


benjaminrich/PCSmisc documentation built on Feb. 11, 2024, 9:25 p.m.