R/acs.R
get_recurrence_covariates.Rdget_recurrence_covariates function assesses the recurrence of each of the identified candidate empirical covariates
based on their frequency of occurrence for each patient in the baseline period and generates three binary recurrence covariates
for each of the identified candidate empirical covariates. This is the second step in the automated covariate selection process.
The first step of identifying empirical candidate covariates is done via get_candidate_covariates function.
See 'Automated Covariate Selection'section below for more details regarding the overall process.
get_recurrence_covariates( df, patientIdVarname, eventCodeVarname, patientIdVector )
| df | The input |
|---|---|
| patientIdVarname | The variable name which contains the patient identifier in the |
| eventCodeVarname | The variable name which contains the covariate codes (eg:- CCS, ICD9) in the |
| patientIdVector | The 1-D vector with all the patient identifiers. This should contain all the patient IDs in the original two
cohorts. This vector can simply be the |
A named list containing two R objects
recurrence_data A data.frame containing all the binary recurrence covariates for all the patients in wide format.
This means that this data.frame will have a dimension with number of rows equal to number of distinct patients and number of
columns equal to number of binary recurrence covariates plus 1 (for the patient Id variable). The binary recurrence covariate is prefixed with
a 'rec_' to indicate that the covariate is a 'reccurrence covariate' and suffixed with '_once', '_sporadic' or '_frequent'.
See details section above for details.
patientIds The list of patient ids present in the original input df. This is exactly the same as the input patientIdVector
The recurrence covariates are generated based on the frequency (counts) of occurrence of each empirical candidate covariates that got
generated by the generate_candidate_covariates function. This is done by looking at the baseline period of each patients and
assessing whether the covariate occurred only once or sporadically or frequently. That is, a maximum of three recurrence covariates
for each candidate covariate is created and returned.
once Indicates whether or not the covariate occurred more than or equal to 1 number of times for the patient
sporadic Indicates whether or not the covariate occurred more than or equal to median (median of non-zero occurrences of
the candidate covariate) number of times for the patient.
frequent Indicates whether or not the covariate occurred more than or equal to upper quartile (75th percentile of non-zero
occurrences of the candidate covariate) number of times for the patient
Note that if two or all three covariates are identical for any of the binary recurrence covariates, only the distinct recurrence covariate
is returned. For example, if once == sporadic == frequent for the candidate covariate (median and upper quartile both are 1), then only the 'once' recurrence covariate is
returned. If once != sporadic == frequent, then 'once' and 'sporadic' is returned. If once == sporadic != frequent, then 'once'
and 'frequent' are returned. If none of three recurrence covariates are identical, then all three are returned.
The theoretical details of the algorithm implemented is detailed in the publication listed below in the References section.
get_recurrence_covariates is the function implementing what is described in the 'Assess Recurrence' section
of the article.
The three steps in automated covariate selection are listed below with the functions implementing the methodology
Identify candidate empirical covariates: get_candidate_covariates
Assess recurrence: get_recurrence_covariates
Prioritize covariates: get_prioritised_covariates
Schneeweiss S, Rassen JA, Glynn RJ, Avorn J, Mogun H, Brookhart MA. High-dimensional propensity score adjustment in studies of treatment effects using health care claims data Epidemiology. 2009;20(4):512-522. doi:10.1097/EDE.0b013e3181a663cc
Dennis Robert dennis.robert.nm@gmail.com
#> person_id index_date event_date event_code event_concept_id domain treatment #> 1 21047 2010-06-10 2010-02-21 78650 44825809 dx 1 #> 2 21047 2010-06-10 2010-03-01 2449 44828786 dx 1 #> 3 21047 2010-06-10 2010-01-19 25002 44836915 dx 1 #> outcome_date last_enrollment_date #> 1 <NA> 2011-01-01 #> 2 <NA> 2011-01-01 #> 3 <NA> 2011-01-01#> person_id treatment outcome_date #> 1 21047 1 <NA> #> 2 378287 1 <NA> #> 3 320862 1 <NA>patientIds <- basetable$person_id step1 <- get_candidate_covariates(df = rwd, domainVarname = "domain", eventCodeVarname = "event_code" , patientIdVarname = "person_id", patientIdVector = patientIds,n = 100, min_num_patients = 10)#>#> [1] TRUEstep2 <- get_recurrence_covariates(df = out1, patientIdVarname = "person_id", eventCodeVarname = "event_code", patientIdVector = patientIds) out2 <- step2$recurrence_data