tstartfun: Compute Starting Time For Counting Process Notation

View source: R/tstartfun.R

tstartfunR Documentation

Compute Starting Time For Counting Process Notation

Description

Computes starting time for follow-up intervals in longitudinal data using counting process notation. Within each subject, starting time equals -1 for the initial record and the previous record's follow-up time for subsequent records.

Usage

tstartfun(id, timevar, data)

Arguments

id

Patient or unit identifier (unquoted symbol, string, or vector).

timevar

Follow-up time variable (unquoted symbol, string, or vector).

data

Data frame containing id and timevar.

Value

Numeric vector of starting times in the same row order as data.

Author(s)

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

Examples

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)
)
mydata1$tstart <- tstartfun(patient, time.days, mydata1)
mydata1

ipw documentation built on Nov. 2, 2026, 1:10 a.m.