Matching controls to cases with time-varying treatment
Source:R/tvt_date2numeric.R
, R/tvt_matching.R
, R/tvt_summary_cases.R
tvt.Rd
Matching controls to cases with time-varying treatment
Usage
tvt_date2numeric(
data,
date_statrisk,
date_treatna,
date_eos,
state_eos,
date_eoatrisk = NULL
)
tvt_matching_date(
data,
date_statrisk,
date_treatna,
date_eos,
state_eos,
date_eoatrisk = NULL,
ratio = 1,
by = NULL
)
tvt_matching_num(
data,
time_atrisk,
time_eos,
state_treat,
state_eos,
ratio = 1,
by = NULL
)
tvt_summary_cases(
data,
date_statrisk,
date_treatna,
date_eos,
state_eos,
date_eoatrisk = NULL,
by = NULL
)
Arguments
- data
A data frame.
- date_statrisk
Column names indicating the date when patients start to be at risk of the treatment.
- date_treatna
Column names indicating the date of the start of the treatment and NA's for untreated subjects.
- date_eos
Column names indicating the date of the end of the study.
- state_eos
Column names indicating the state at the end of the study.
- date_eoatrisk
Column names indicating the date when patient end to be "at risk of the treatment". Specify
date_eos
the ending of the "at risk of the treatment" period corresponds to the end of the study.- ratio
Integer. The number of controls per cases.
- by
Column names indicating a grouping factor for the matching.
- time_atrisk
Column names with integer representing the length of the "at risk of the treatment" period.
- time_eos
Column names with integer representing the length of the study.
- state_treat
Column names indicating if the subject experimented the treatment.
Value
The tvt_summary_cases()
function return a tibble with information of control candidates for each case.
The tvt_date2numeric()
convert the encoding of the event from dates to numeric.
The tvt_matching_date()
and tvt_matching_num()
perform the matching algorithm.
Examples
data("tvtdata")
tvtdata_num <- tvt_date2numeric(tvtdata,stos,treatna,eos,eos01)
tvt_sum <- tvt_summary_cases(tvtdata,stos,treatna,eos,eos01, by = fct)
set.seed(42)
tvt_match<- tvt_matching_date(tvtdata,stos,treatna,eos,eos01)
set.seed(42)
tvt_match2 <- tvt_matching_num(tvtdata_num,time_atrisk,time_eos,state_eos,state_treat)