get_candidate_covariates {autoCovariateSelection}R Documentation

Generate candidate empirical baseline covariates based on prevalence in the baseline period


get_candidate_covariates function generates the list of candidate empirical covariates based on their prevalence within each domains (dimensions). This is the first step in the automated covariate selection process. See 'Automated Covariate Selection' section below for more details regarding the overall process.


  n = 200,
  min_num_patients = 100



The input data.frame. This should contain at least 3 fields containing information on patient identifier, covariate codes and domain names of covariate codes in a long format. Any other fields containing values such as dates, treatment group are optional and will be ignored for this analysis


The variable(field) name which contains the domain of the covariate in the df. The domains are usually diagnosis, procedures and medications.


The variable name which contains the covariate codes (eg:- CCS, ICD9) in the df


The variable name which contains the patient identifier in the df


The 1-D vector with all the patient identifiers. The length of this vector should be equal to the number of distinct patients in the df. This vector is not really used in the function analysis per se. This is used only to return the same back as function output because the filtered df based on covars will likely not contain all patients in the input df because there could be patients for whom no records were found for any of the identified covars and they will thus be not present in the filtered df which is also an output of this function. The patientIds vector output will contain all original patients and by returning this vector, it can later be used in the next steps of automated covariate selection because each step is dependent on previous steps and information on patients who did not have any identified covars is also important for the next steps. This is why this vector is an input as well as an output, without affecting the analysis of this function.


The maximum number of empirical candidate baseline covariates that should be returned within each domain. By default, n is 200


Minimum number of patients that should be present for each covariate to be selected for selection. To be considered for selection, a covariate should have occurred for a minimum min_num_patients in the baseline period


The theoretical details of the high-dimensional propensity score (HDPS) algorithm is detailed in the publication listed below in the References section. get_candidate_covariates is the function implementing what is described in the 'Identify candidate empirical covariates' section of the article.


A named list containing three R objects

Automated Covariate Selection

The three steps in automated covariate selection are listed below with the functions implementing the methodology

  1. Identify candidate empirical covariates: get_candidate_covariates

  2. Assess recurrence: get_recurrence_covariates

  3. Prioritize covariates: get_prioritised_covariates


Dennis Robert


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


head(rwd, 3)
#select distinct elements that are unique for each patient - treatment and outcome
basetable <- rwd %>% select(person_id, treatment, outcome_date) %>% distinct()
head(basetable, 3)
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)
out1 <- step1$covars_data #this will be input to get_recurrence_covariates() function

[Package autoCovariateSelection version 1.0.0 Index]