Pass a one-row-per-patient data.frame and get back a data.frame with one row per clone.

create_clones(
  df,
  id,
  event,
  time_to_event,
  exposure,
  time_to_exposure,
  ced_window = NULL
)

Arguments

df

A data.frame with one row per patient.

id

The name of the column in df that contains the patient identifier.

event

The name of the column in df that contains the event of interest.

time_to_event

The name of the column in df that contains the time to event.

exposure

The name of the column in df that contains the exposure.

time_to_exposure

The name of the column in df that contains the time to exposure.

ced_window

The date at which the clinical eligibility window closes. Can be left empty, in which case the clinical eligibility window is assumed to be part of exposure and time_to_exposure

Value

A data.frame with one row per clone.

References

Maringe, Camille, et al. "Reflection on modern methods: trial emulation in the presence of immortal-time bias. Assessing the benefit of major surgery for elderly lung cancer patients using observational data." International journal of epidemiology 49.5 (2020): 1719-1729.

Examples


# Load the toy dataset
data(toy_df)

# Create clones
clones <- create_clones(toy_df, 
                        id = "id", 
                        event = "death", 
                        time_to_event = "fup_obs", 
                        exposure = "surgery", 
                        time_to_exposure = "timetosurgery", 
                        ced_window = 365.25/2)