tstartfun: Compute Starting Time For Counting Process Notation

View source: R/tstartfun.R

tstartfunR Documentation

Compute Starting Time For Counting Process Notation

Description

Function to compute starting time for intervals of follow-up, when using the counting process notation. Within each unit under observation (usually individuals), computes starting time equal to:

  • time of previous record when there is a previous record.

  • -1 for first record.

Usage

tstartfun(id, timevar, data)

Arguments

id

numerical vector, uniquely identifying the units under observation, within which the longitudinal measurements are taken.

timevar

numerical vector, representing follow-up time, starting at 0.

data

dataframe containing id and timevar.

Value

Numerical vector containing starting time for each record. In the same order as the records in data, to facilitate merging.

Missing values

Currently, id and timevar should not contain missing values.

Author(s)

Willem M. van der Wal willem@vanderwalresearch.com, Ronald B. Geskus rgeskus@oucru.org

References

Van der Wal W.M. & Geskus R.B. (2011). ipw: An R Package for Inverse Probability Weighting. Journal of Statistical Software, 43(13), 1-23. doi: 10.18637/jss.v043.i13.

See Also

basdat, haartdat, ipwplot, ipwpoint, ipwtm, timedat, tstartfun.

Examples

#data
mydata1 <- data.frame(
   patient = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2),
   time.days = c(14, 34, 41, 56, 72, 98, 0, 11, 28, 35))

#compute starting time for each interval
mydata1$tstart <- tstartfun(patient, time.days, mydata1)

#result
mydata1

#see also ?ipwtm for example

ipw documentation built on Jan. 7, 2023, 9:08 a.m.

Related to tstartfun in ipw...