Learn R Programming

ipw (version 1.0-1)

tstartfun: 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.

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. http://www.jstatsoft.org/v43/i13/.

See Also

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

Examples

Run this code
#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

Run the code above in your browser using DataLab