blk.changeFromBaseline: Compute Change from Baseline and Relative Time

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/PCSmisc.R

Description

These functions compute change from baseline in a block-format data set.

Usage

1
2
3
4
5
blk.changeFromBaseline(x, id, baseline = blk.singleValue(x, id, ind = bl.ind, select = bl.select),
                       bl.ind = NULL, bl.select = "first", diff.op = percentChange, ...)

blk.relativeTime(time, id, baseline = blk.singleValue(time, id, ind=bl.ind, select=bl.select),
                 bl.ind = NULL, bl.select = "first", diff.op = difftime.default, ...)

Arguments

x, time

A vector in block-format with respect to id.

id

A valid block-format ID.

baseline

A vector of basline values or times, one for each level of id.

bl.ind

A logical vector that indicates elements of x or time used for baseline specification.

bl.select

How to select a single baseline from a vector of possibilities.

diff.op

A function that computes differences in x or time.

...

Further arguments passed to diff.op.

Details

A unique baseline value for each level of id is required. The baseline values can be specified in two ways: directly as a vector of length nlevels{id}, or indirectly by the arguments bl.ind and bl.select which are passed to blk.singleValue.

Relative time refers to change from baseline in a time variable, so there are two functions which are essentially identical, except for the default value of diff.op. By default, blk.changeFromBaseline computes the percent change from baseline. When applied to date/time objects (class lind{POSIXt}), the default diff.op for blk.relativeTime computes relative time in hours.

Value

A vector in block-format with respect to id containing the change from baseline (or relative time) for x (or time).

Author(s)

Ben Rich <[email protected]>

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
require(nlme)
data(Phenobarb)
dat <- Phenobarb[1:56,]  # First 4 subjects


cbind(dat, PCT.CHG=blk.changeFromBaseline(dat$conc, asID(dat$Subject), bl.ind=(!is.na(dat$conc))))


# Relative time from calendar date and clock time
# -----------------------------------------------

# This data already has relative time, so for this example we will
# re-create a calendar date and clock time from made-up baseline times.

baseline <- strptime(c("2005-04-13 8:05:00", "2005-04-16 7:59:00", "2005-03-31 9:00:00", "2005-04-19 8:35:00"), format="%F %T")

# Back-calcuate the calendar date and clock time
dat$time2 <- blk.repeatValue(baseline, id2=asID(dat$Subject)) + as.difftime(dat$time, units="hours")

# Now, recalcuate the relative time assuming that only time2 was specified
cbind(dat, REL.TIME=blk.relativeTime(dat$time2, asID(dat$Subject), bl.ind=(!is.na(dat$dose))))

benjaminrich/PCSmisc documentation built on Dec. 17, 2017, 12:50 a.m.