Skip to contents

This function returns a data.frame with the relevant information on immunization for the study. An individual is considered immunized after the characteristic time for the immune response of the vaccine passes. This time is provided to the function by the parameter immunization_delay. By default, it is set to 0. The function searches for vaccine dates based on the end of the follow-up period of each individual defined by the censoring date (if provided), outcome delay (if present), and end of the study.

The function also works with vaccination information spread across several columns. If this is the case, the parameter vacc_date_col must be passed as a vector with the names of all the columns to use (see example). The function uses by default the latest date found. However, it can also select the first date by setting take_first = TRUE.

The function returns a column with the immunization date (immunization) and a vaccine status column (vaccine_status) that is constructed based on immunization. For several vaccines, the function also returns the name of the column of the vaccine that was selected as immunizing (immunizing_dose). If different custom names (e.g., brands) are associated with each vaccine date, the function can return the custom name of the vaccine selected as immunizing. This information must be passed in the parameter vacc_name_col, as a vector in the same order as vacc_date_col.

Usage

make_immunization(
  data_set,
  outcome_date_col,
  censoring_date_col = NULL,
  vacc_date_col,
  vacc_name_col = NULL,
  vaccinated_status = "v",
  unvaccinated_status = "u",
  immunization_delay = 0,
  end_cohort,
  take_first = FALSE
)

Arguments

data_set

data.frame with cohort information (see example).

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date. NULL by default.

vacc_date_col

Name of the column(s) that contain the vaccine dates.

vacc_name_col

Name of the column(s) that contain custom vaccine names for the vaccines (e.g. brand name, type of vaccine)

vaccinated_status

Status assigned to the vaccinated population. Default is v.

unvaccinated_status

Status assigned to the unvaccinated population. Default is u.

immunization_delay

Characteristic time in days before the patient is considered immune.

end_cohort

End date of the study.

take_first

FALSE: takes the latest vaccine date. TRUE: takes the earliest vaccine date.

Value

Original data.frame passed in data_set and additional columns containing information on the immunization.

Examples

# Load data
data(cohort_data)
#> Warning: data set ‘cohort_data’ not found
# Define start and end dates of the study
start_cohort <- as.Date("2044-01-01")
end_cohort <- as.Date("2044-12-31")

# Create `data.frame` with information of immunization
cohortdata <- make_immunization(
  data_set = cohortdata,
  outcome_date_col = "death_date",
  censoring_date_col = "death_other_causes",
  immunization_delay = 14,
  vacc_date_col = "vaccine_date_2",
  end_cohort = end_cohort
)
# `immunization_date` and `vaccine_status` are added to `cohortdata`
head(cohortdata)
#>         id sex age death_date death_other_causes vaccine_date_1 vaccine_date_2
#> 1 afade1b2   F  37       <NA>               <NA>           <NA>           <NA>
#> 2 556c8c76   M  19       <NA>               <NA>           <NA>           <NA>
#> 3 04edf85a   M  50       <NA>               <NA>           <NA>           <NA>
#> 4 7e51a18e   F   8       <NA>               <NA>           <NA>           <NA>
#> 5 c5a83f56   M  66       <NA>               <NA>           <NA>           <NA>
#> 6 7f675ec3   M  29       <NA>               <NA>     2044-04-09     2044-04-30
#>   vaccine_1 vaccine_2 immunization_date vaccine_status
#> 1      <NA>      <NA>              <NA>              u
#> 2      <NA>      <NA>              <NA>              u
#> 3      <NA>      <NA>              <NA>              u
#> 4      <NA>      <NA>              <NA>              u
#> 5      <NA>      <NA>              <NA>              u
#> 6    BRAND1    BRAND1        2044-05-14              v