Skip to contents

Calculates time intervals between dates or from pre-calculated values. Time intervals form the basis of person-time follow-up calculations in survival analysis. Person-time follows the accumulated time that participants contribute to a study while being at risk for the event of interest, accounting for varying entry times and censoring. Person-time is typically expressed in person-days, person-months, or person-years depending on the study duration and outcome frequency.

Usage

timeinterval(
  data,
  dx_date,
  fu_date,
  time_format = "ymd",
  output_unit = "months",
  use_landmark = FALSE,
  landmark_time = 3,
  add_times = TRUE
)

Arguments

data

The data as a data frame.

dx_date

Column containing start dates

fu_date

Column containing end dates

time_format

.

output_unit

.

use_landmark

.

landmark_time

.

add_times

.

Value

A results object containing:

results$todoa html
results$personTimeInfoa html
results$summarya html
results$calculated_timean output

Examples

# Calculate time intervals for person-time analysis:
# timeinterval(
#   data = study_data,
#   dx_date = "diagnosis_date",
#   fu_date = "followup_date",
#   output_unit = "months"
# )