Title: Estimate Vaccine Effectiveness Based on Different Study Designs
Version: 1.0.0
Description: Provides tools for estimating vaccine effectiveness and related metrics. The 'vaccineff_data' class manages key features for preparing, visualizing, and organizing cohort data, as well as estimating vaccine effectiveness. The results and model performance are assessed using the 'vaccineff' class.
License: MIT + file LICENSE
URL: https://github.com/epiverse-trace/vaccineff, https://epiverse-trace.github.io/vaccineff/
BugReports: https://github.com/epiverse-trace/vaccineff/issues
Depends: R (≥ 4.0.0)
Imports: checkmate, ggplot2, linelist, MatchIt, rlang, scales, stats, survival
Suggests: knitr, rmarkdown, spelling, testthat (≥ 3.0.0)
VignetteBuilder: knitr
Config/Needs/website: epiverse-trace/epiversetheme
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2024-11-28 15:34:19 UTC; dsquevedovega
Author: David Santiago Quevedo ORCID iD [aut], Zulma M. Cucunubá ORCID iD [aut, cre], International Development Research Center (IDRC) [fnd], Geraldine Gómez Millán ORCID iD [ctb], Pratik Gupte ORCID iD [ctb], Érika J Cantor ORCID iD [ctb], Santiago Loaiza ORCID iD [ctb], Jaime Pavlich-Mariscal ORCID iD [ctb], Hugo Gruson ORCID iD [ctb], Chris Hartgerink ORCID iD [ctb], Felipe Segundo Abril ORCID iD [ctb], Joshua W. Lambert ORCID iD [ctb], Julian Otero ORCID iD [ctb], Pontificia Universidad Javeriana [cph]
Maintainer: Zulma M. Cucunubá <tracelacdev@gmail.com>
Repository: CRAN
Date/Publication: 2024-11-29 09:30:02 UTC

vaccineff: Estimate Vaccine Effectiveness Based on Different Study Designs

Description

logo

Provides tools for estimating vaccine effectiveness and related metrics. The 'vaccineff_data' class manages key features for preparing, visualizing, and organizing cohort data, as well as estimating vaccine effectiveness. The results and model performance are assessed using the 'vaccineff' class.

Author(s)

Maintainer: Zulma M. Cucunubá tracelacdev@gmail.com (ORCID)

Authors:

Other contributors:

See Also

Useful links:


Adjust Exposure for Static Matching

Description

This function removes the pairs whose exposure times do not match. This happens when the outcome of the unvaccinated individual occurs before the vaccination date of their partner.

Usage

adjust_exposure(
  matched_cohort,
  outcome_date_col,
  censoring_date_col,
  immunization_date,
  start_cohort,
  end_cohort
)

Arguments

matched_cohort

data.frame with matched cohort from match_cohort_.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

start_cohort

Start date of the study.

end_cohort

End date of the study.

Value

data.frame with matched population and corrected exposure times.


Balance of Vaccinated/Unvaccinated Groups

Description

This function creates a summary after matching.

Usage

balance_summary(
  data_set,
  nearest,
  exact,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status
)

Arguments

data_set

data.frame to assess matching balance.

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers).

exact

Name(s) of column(s) for exact matching

vacc_status_col

Name of the column containing the vaccination.

vaccinated_status

Status assigned to the vaccinated population.

unvaccinated_status

Status assigned to the unvaccinated population.

Value

Summary data.frame with the balance of each variable by vaccine status. Numeric variables are reported with means, and categorical/factor variables are reported with proportions. In both cases, the Standardized Mean Difference (SMD) is calculated.


Capture Warnings

Description

This function captures the warnings generated by an expression without printing them to the console. It returns both the result of the expression and the captured warnings. This is useful for avoiding warnings appearing during routines, such as an iterative process. To suppress or "muffle" a warning, it uses invokeRestart("muffleWarning"). The new.env() function creates a new environment that is isolated from other environments. This allows the function to store and modify data (in this case, warnings) without affecting the global environment or any other environment in the R session.

Usage

capture_warnings(expr, warn_env = new.env())

Arguments

expr

An expression to evaluate.

warn_env

An optional environment to store the warnings. If not provided, a new environment is created.

Value

A list containing two elements:

result

The result of evaluating the expression.

warnings

A character vector of the warnings generated during the evaluation of the expression.


Check Correctness of data_set

Description

This auxiliary function checks that the type of the object provided in data_set is a data.frame and that the specified columns are included in it.

Usage

check_dataset(data_set, columns)

Arguments

data_set

data.frame.

columns

A vector of column names that should be present in data_set.

Value

This function does not return a value.


Check Correctness of Inputs in make_vaccineff_data

Description

This auxiliary function checks the correctness of the inputs provided to make_vaccineff_data.

Usage

check_vaccineff_inputs(
  data_set,
  outcome_date_col,
  censoring_date_col,
  vacc_date_col,
  vacc_name_col,
  vaccinated_status,
  unvaccinated_status,
  immunization_delay,
  end_cohort,
  match,
  exact,
  nearest,
  take_first
)

Arguments

data_set

data.frame with cohort information.

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). If provided, must be of the same length as vacc_date_col.

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. Default is 0.

end_cohort

End date of the study.

match

TRUE: cohort matching is performed. Default is FALSE

exact

Name(s) of column(s) for exact matching. Default is NULL.

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers). Default is NULL.

take_first

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

Value

This function does not return a value.


Calculate Vaccine Coverage

Description

This function returns the vaccination coverage of a dose along the cohort study. The coverage can be calculated grouped by year, day, and month. This must be specified in the parameter unit. If there are no records for some dates, the function assigns 0 instead of NA to calculate the cumulative coverage.

Usage

coh_coverage(
  data_set,
  vacc_date_col,
  unit = c("day", "month", "year"),
  date_interval = NULL
)

Arguments

data_set

data.frame with cohort information.

vacc_date_col

Name of the column(s) that contain the vaccine date to calculate the coverage.

unit

Aggregation unit, must be either "year", "month", or "day".

date_interval

If NULL, the function calculates the coverage interval based on the min() and max() of the vacc_date_col. It is also possible to pass a custom date interval to truncate or expand the date interval (see example).

Value

data.frame with the number of vaccine doses per date, cumulative count of doses, and vaccine coverage.


Function to Estimate the Vaccine Effectiveness Using Hazard Ratio

Description

The function relies on the implementation of the Cox model for proportional hazards from the package {survival} The proportional hazards hypothesis is tested using the Schoenfeld test, and the resultant p-value is provided in the results. Log-log plots are also calculated using the Kaplan-Meier survival estimator to provide a visual test for the proportional hazards hypothesis. The function returns a list with the method called, the estimation of VE (CI95%), the p-value of the Schoenfeld test, and the log-log plot.

Usage

coh_eff_hr(
  data_set,
  outcome_status_col,
  time_to_event_col,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status,
  start_cohort,
  end_cohort
)

Value

VE (CI95%), output from cox_model, prediction from cox_model, and output from km_model


Cohort data on vaccineff

Description

Subset of data from an anonymised, real-world dataset produced as part of the early stage of the immunization program against COVID-19 in Bogota, Colombia between February 2021 and December 2021. Cohort dataset contains registers of homologous schemes for two different brands for adults aged 50 years or older. This cohort received two doses of a vaccine aimed at reducing the risk of death. All the registers were anonymised and de-identified to preserve the privacy of data. The dataset includes disaggregated information on the first and second vaccine doses (vaccine_date1, vaccine_date2, vaccine1, and vaccine2) for each participant and relevant demographic details (sex and age). Additionally, the dataset includes the dates of two outcomes: death associated with COVID-19 (death_date) and death from other causes (death_other_causes).

Usage

cohortdata

Format

cohortdata

id

Anonymous ID of the individual

sex

Sex F/M

age

Age (50-100)

death_date

Registered death by COVID-19

death_other_causes

Registered death by other causes

vaccine_date_1

Registered date of the first dose

vaccine_date_2

Registered date of the second dose

vaccine_1

Brand of the first dose

vaccine_2

Brand of the second dose

Examples

cohortdata

Internal function to calculate Cox-PH model and related metrics.

Description

Internal function to calculate Cox-PH model and related metrics.

Usage

cox_model(
  data_set,
  outcome_status_col,
  time_to_event_col,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status
)

Value

List with data from Cox model: hr - hazard ratio (CI95%) p_value {survival} object with model {survival} object with Schoenfeld test


Internal function to calculate prediction from Cox model

Description

Internal function to calculate prediction from Cox model

Usage

cox_model_prediction(cox_model, vaccinated_status, unvaccinated_status)

Arguments

cox_model

Result from cox_model function

Value

data.frame containing time: time-to-event until at logtime: log of time-to-event hazard: estimated hazard from model surv: estimated survival probability from model loglog: -log(-log(survival probability)) strata: vaccinated/unvaccinated status


Estimate Vaccine Effectiveness (VE)

Description

This function provides methods for estimating VE. It relies on the Kaplan-Meier estimator and the Cox model for proportional hazards from the {survival} package. Currently, the default method is VE = 1 - HR, where HR is the Hazard Ratio calculated using the Cox model. The proportional hazards assumption is tested using the Schoenfeld test, with the p-value provided in the results. Log-log plots are also generated using the Kaplan-Meier estimator for a visual test of the proportional hazards hypothesis. The function uses column names provided in the tags outcome_status_col, time_to_event_col, and vaccine_status_col of the linelist object and status names from make_vaccineff_data. The return is an ⁠S3 class⁠ object with the VE (CI95%), results from the Cox model, and the Kaplan-Meier estimator. This object is compatible with summary and plot methods.

Usage

estimate_vaccineff(vaccineff_data, at)

Arguments

vaccineff_data

Object of the class vaccineff_data with vaccineff data.

at

Number of days at which VE is estimated from the beginning of the follow-up period.

Value

Object of the class vaccineff: a list with results from the estimation of VE. ve: data.frame with VE(CI95%) cox_model: survival object with Cox model results kaplan_meier: survival object with Kaplan-Meier estimator

Examples


# Load example data
data("cohortdata")

# Create `vaccineff_data`
vaccineff_data <- make_vaccineff_data(data_set = cohortdata,
  outcome_date_col = "death_date",
  censoring_date_col = "death_other_causes",
  vacc_date_col = "vaccine_date_2",
  vaccinated_status = "v",
  unvaccinated_status = "u",
  immunization_delay = 15,
  end_cohort = as.Date("2021-12-31"),
  match = TRUE,
  exact = c("age", "sex"),
  nearest = NULL
)

# Estimate the Vaccine Effectiveness (VE)
ve <- estimate_vaccineff(vaccineff_data, 90)

# Print summary of VE
summary(ve)

# Generate loglog plot to check proportional hazards
plot(ve, type = "loglog")

# Generate Survival plot
plot(ve, type = "surv", percentage = FALSE, cumulative = FALSE)


Internal function to extract summary output from {survival} models.

Description

Internal function to extract summary output from {survival} models.

Usage

extract_surv_model(model, start_cohort, end_cohort)

Arguments

model

{survival} object containing the model

Value

data.frame with survival data


Construct age-group variable from age column

Description

This method splits an age interval from min_val to max_val into intervals of size step. If the method finds ages greater or equal than max_val it assigns the string ">max_val". By default min_val is set to 0, however it can be assigned by convenience. If the method finds ages lower or equal than min_val it assigns the string "<min_val-1". The function warns when (max_val - min_val) is not an integer multiple of step. In that case the last interval is truncated to the upper value closest to max_val for which (closest_upper - min_val) is multiple of step.

Usage

get_age_group(data_set, col_age, max_val, min_val = 0, step)

Arguments

data_set

data.frame with at least a column containing the age information

col_age

Name of the column containing the age information

max_val

Maximum value of age interval to split

min_val

Minimum value of age interval to split

step

Step used to split the age interval

Value

Column of type factor with the same length as the number of rows in data_set, with levels corresponding to age bins between min_val and max_val. Ages above max_val are represented as ⁠>max_val⁠.

Examples

# load data provided with the package
data(cohortdata)

# assign age groups as a column of the `data.frame`
cohortdata$age_group <- get_age_group(
  data_set = cohortdata,
  col_age = "age",
  max_val = 80,
  step = 10
)

# view the `data.frame` with new column
head(cohortdata)

Create Censoring date by Pairs

Description

This function creates the censoring date of the pairs by inheriting the minimum date in which any of the partners has a censoring event. Two conditions are checked to inherit a censoring date in a pair.

  1. Individual censoring occurs before individual event;

  2. If an outcome happens before the censoring of the partner no censoring is inherited by the other.

Usage

get_censoring_after_match(data_set, outcome_date_col, censoring_date_col)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.


Calculate Exposure Time

Description

This auxiliary function calculates the exposure time of individuals starting from the t0_follow_up date defined based on whether a matching strategy is invoked or not. The end of the exposure time is assigned based on the follow hierarchy outcome_status -> censoring_date -> end_cohort

Usage

get_exposure_time(data_set, outcome_date_col, censoring_date_col, end_cohort)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

end_cohort

End date of the study.

Value

column with exposure time per individual.


Construct Immunization Date

Description

This function constructs the immunization date per individual by searching for the vaccine dates that satisfy the condition: vacc_date_col + immunization_delay <= limit_date, where limit_date is defined following the hierarchy: censoring_date_col, outcome_date_col, end_cohort. If a date is not provided/found the function takes the next one in the hierarchy. If several columns with vaccine dates are provided, the function selects by default the closest vaccine date to limit_date. However, it can also select the first vaccine date by setting take_first = TRUE.

Usage

get_immunization_date(
  data_set,
  outcome_date_col,
  censoring_date_col,
  immunization_delay,
  vacc_date_col,
  end_cohort,
  take_first = FALSE
)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

immunization_delay

Characteristic time in days before the patient is considered immune.

vacc_date_col

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

end_cohort

End date of the study.

take_first

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

Value

Immunization date


Return Column Name Associated to Immunizing Vaccine

Description

This function is used in cases where several columns with vaccine dates are provided by the user. It returns the name of the column of the vaccine used as immunizing. The parameters are set in agreement with get_immunization_date.

Usage

get_immunization_dose(
  data_set,
  immunization_date_col,
  vacc_date_col,
  immunization_delay
)

Arguments

data_set

data.frame with cohort information.

vacc_date_col

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

immunization_delay

Characteristic time in days before the patient is considered immune.

Value

Name of the column taken as immunizing vaccine for each register.


Construct Vaccine Name Associated to Immunizing Vaccine

Description

This function is used in cases where several columns with vaccine dates and different names are provided by the user. It returns a column with the name of the vaccine used as immunizing. The parameters are set in agreement with get_immunization_date.

Usage

get_immunization_vaccine(
  data_set,
  immunization_date_col,
  vacc_date_col,
  vacc_name_col,
  immunization_delay
)

Arguments

data_set

data.frame with cohort information.

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)

immunization_delay

Characteristic time in days before the patient is considered immune.

Value

Custom vaccine names of the immunizing vaccine.


Construct Time-to-Event at

Description

This function returns both the time-to-event until a reference number of days, as provided in at, and the outcome status at the same point. It uses the exposure time as an auxiliary variable to calculate the time-to-event. The starting point for counting the time-to-event is t0_follow_up, which is determined based on whether a matching strategy is used or not. If the event occurs before the reference date, the end date of the exposure period is used to calculate the time-to-event. This accounts for whether censoring or an event occurred. The outcome status is determined based on whether the outcome date coincides with the end of the follow-up period.

Usage

get_time_to_event_at(
  data_set,
  outcome_date_col,
  censoring_date_col,
  end_cohort,
  at
)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

end_cohort

End date of the study.

at

Time to truncate the follow-up period

Value

data.frame containing time_to_event and outcome_status


Iterate Match

Description

This function iterates to re-match registers that were removed after adjusting exposure times. To avoid generating the same pairs already removed, each iteration is split in two steps, one for the removed vaccinated population and the other for the unvaccinated. A tryCatch validation handles errors when no matches can be generated due to the lack of treated or untreated individuals. The threshold for the maximum number of iterations is the total removed population for the first iteration. The algorithm iterates until no new adjusted pairs are generated or the maximum number of iterations is reached.

Usage

iterate_match(
  all,
  matched,
  adjusted,
  outcome_date_col,
  censoring_date_col,
  immunization_date_col,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status,
  exact,
  nearest,
  start_cohort,
  end_cohort
)

Arguments

all

data.frame with the entire cohort.

matched

data.frame with the matched cohort.

adjusted

data.frame with the adjusted cohort to calculate removed cases. Default is NULL, which returns 0.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

immunization_date_col

Name of the column that contains the immunization date to set the beginning of the follow-up period (t0_follow_up).

vacc_status_col

Name of the column containing the vaccination.

vaccinated_status

Status assigned to the vaccinated population.

unvaccinated_status

Status assigned to the unvaccinated population.

exact

Name(s) of column(s) for exact matching

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers).

start_cohort

Start date of the study.

end_cohort

End date of the study.

Value

data.frame with adjusted pairs after iterating.


Internal function to calculate Kaplan-Meier model and related metrics.

Description

Internal function to calculate Kaplan-Meier model and related metrics.

Usage

km_model(
  data_set,
  outcome_status_col,
  time_to_event_col,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status,
  start_cohort,
  end_cohort
)

Value

data.frame with data from KM model: "time", "date", "strata", "n.risk", "n.event", "n.censor", "surv", "lower", "upper", "cumincidence", "cumincidence_lower", "cumincidence_upper"


Construct Information of Immunization

Description

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. 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,
  vacc_date_col,
  vacc_name_col,
  vaccinated_status,
  unvaccinated_status,
  immunization_delay,
  end_cohort,
  take_first = FALSE
)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

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.

unvaccinated_status

Status assigned to the unvaccinated population.

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.


Construct vaccineff_data Object

Description

This function constructs an S3 object of the class vaccineff_data that contains all the relevant information for the study. to estimate the effectiveness.

Usage

make_vaccineff_data(
  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,
  match = FALSE,
  exact = NULL,
  nearest = NULL,
  take_first = FALSE,
  t0_follow_up = NULL
)

Arguments

data_set

data.frame with cohort information.

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). If provided, must be of the same length as vacc_date_col.

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. Default is 0.

end_cohort

End date of the study.

match

TRUE: cohort matching is performed. Default is FALSE

exact

Name(s) of column(s) for exact matching. Default is NULL.

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers). Default is NULL.

take_first

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

t0_follow_up

Column with the initial dates of the follow-up period. This column is only used if match = FALSE. If not provided, the follow-up period starts at start_cohort. Default is NULL.

Value

An S3 object of class vaccineff_data with all the information and characteristics of the study. data.frames are converted into an object of class linelist to easily handle with the data.

Examples


# Load example data
data("cohortdata")

# Create `vaccineff_data`
vaccineff_data <- make_vaccineff_data(data_set = cohortdata,
  outcome_date_col = "death_date",
  censoring_date_col = "death_other_causes",
  vacc_date_col = "vaccine_date_2",
  vaccinated_status = "v",
  unvaccinated_status = "u",
  immunization_delay = 15,
  end_cohort = as.Date("2021-12-31"),
  match = TRUE,
  exact = c("age", "sex"),
  nearest = NULL
)

# Print summary of data
summary(vaccineff_data)

# Plot vaccine coverage
plot(vaccineff_data)


Match Cohort to Reduce Observational Bias

Description

This function builds pairs of vaccinated and unvaccinated individuals with similar characteristics. The function relies on the matching algorithm implemented in the package {MatchIt}, setting, by default, method = "nearest", ratio = 1, and distance = "mahalanobis". Exact and near characteristics are accepted, passed in the parameters exact and nearest, respectively. The parameter nearest must be provided together with the calipers as a named vector (e.g., nearest = c(characteristic1 = n1, characteristic2 = n2), where n1 and n2 are the calipers). The default matching method of the function is static. This means that pairs are matched once, without taking into account their vaccination, censoring, and outcome dates. After this, the pairs whose exposure time do not coincide are removed to avoid negative time-to-events. The function returns a matched and adjusted by exposure cohort, with information of the beginning of follow-up period of pairs (t0_follow_up), corresponding to the vaccination date of the vaccinated individual, the individual time-to-event (time_to_event) and the outcome status (outcome_status), both taking into account the right-censoring dates. Pairs are censored if the vaccinated or unvaccinated partner was previously censored (i.e., if censoring_date_col is informed) and the censor occurs before their outcomes. Rolling calendar matching method will be included in future releases.

Usage

match_cohort(
  data_set,
  outcome_date_col,
  censoring_date_col,
  start_cohort,
  end_cohort,
  nearest,
  exact,
  immunization_date_col,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status
)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

start_cohort

Start date of the study.

end_cohort

End date of the study.

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers).

exact

Name(s) of column(s) for exact matching

immunization_date_col

Name of the column that contains the immunization date to set the beginning of the follow-up period (t0_follow_up).

vacc_status_col

Name of the column containing the vaccination.

vaccinated_status

Status assigned to the vaccinated population.

unvaccinated_status

Status assigned to the unvaccinated population.

Value

object of the class match. List with results from static match: match: data.frame with adjusted cohort, summary: matching summary, balance_all: balance of the cohort before matching, balance_matched: balance of the cohort after matching.

Four columns are added to the structure provided in data_set: subclass: ID of, matched pair, t0_follow_up: beginning of follow-up period for pair, time_to_event: time to event, and outcome_status: outcome status (1:positive, 0: negative).


Match Cohort Using Mahalanobis Distance

Description

This function constructs pairs of vaccinated and unvaccinated individuals with similar characteristics. It relies on the matching algorithm implemented in the package {MatchIt}. By default, the function uses method = "nearest", ratio = 1, and distance = "mahalanobis" to perform the matching.

Usage

match_cohort_(data_set, vacc_status_col, exact = NULL, nearest = NULL)

Arguments

data_set

data.frame with cohort information.

vacc_status_col

Name of the column containing the vaccination.

exact

Name(s) of column(s) for exact matching

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers).

Value

data.frame with the matched population.


Match Information by Pairs

Description

This function matches numeric/date information of a pair provided in the column column_to_match. This matching procedure is required for sharing the censoring information and the exposure times when adjusting and removing negative exposures generated by incoherent exposure dates.

Usage

match_pair_info(data_set, column_to_match, criteria = c("min", "max"))

Arguments

data_set

data.frame with cohort information.

column_to_match

The name of the column that contains the information shared by the pairs.

criteria

Selection criteria when both individuals provide information. This can be the minimum (min) or maximum (max) value.


Constructs Summary with Results from Matching

Description

This function creates a summary for the results from cohort matching. It provides counts grouped by vaccine status for the entire population, the matched and unmatched populations.

Usage

match_summary(all, matched, vacc_status_col)

Arguments

all

data.frame with the entire cohort.

matched

data.frame with the matched cohort. calculate removed cases. Default is NULL, which returns 0.

vacc_status_col

Name of the column containing the vaccination.

Value

Summary data.frame with counts by vaccine status for: all, matched, unmatched, and removed.


Function for Extracting Vaccine Effectiveness Plot

Description

This function creates plots from an object of class vaccineff. It returns a Log-Log plot when type = "loglog", or a Survival curve when type = "surv". Survival plots can be shown as cumulative incidence (cumulative = TRUE), and using percentages (percentage = TRUE).

Usage

## S3 method for class 'vaccineff'
plot(
  x,
  type = c("loglog", "surv"),
  cumulative = FALSE,
  percentage = FALSE,
  ...
)

Arguments

x

Object of class vaccineff.

type

Type of plot. Options are loglog and surv.

cumulative

If TRUE, the survival curve is shown as cumulative incidence.

percentage

If TRUE, results are shown on a percentage scale.

...

Additional arguments passed to other functions.

Value

Plot extracted from vaccineff.


Function for Extracting Vaccineff Data Plot

Description

This function returns a plot of the vaccine coverage or the cumulative coverage (if cumulative = TRUE). The return is a 2-axis ggplot2 element with the number of vaccines per date on the left axis and the coverage per date on the right axis. When a matching routine is performed, the left axis also accounts for the doses of the matched cohort.

Usage

## S3 method for class 'vaccineff_data'
plot(x, date_interval = NULL, cumulative = FALSE, ...)

Arguments

x

Object of class vaccineff_data.

date_interval

If NULL, the function calculates the coverage interval

cumulative

If TRUE, returns the cumulative number of doses over the time window.

...

Additional arguments passed to other functions.

Value

Plot extracted from vaccineff.


Plot Vaccine Coverage

Description

This function returns a plot of the vaccine coverage or the cumulative coverage (if cumulative = TRUE). The return is a 2-axis ggplot2 element with the number of vaccines per date on the left axis and the coverage per date on the right axis. When a matching routine is performed, the left axis also accounts for the doses of the matched cohort.

Usage

plot_coverage(vaccineff_data, date_interval = NULL, cumulative = FALSE)

Arguments

vaccineff_data

Object of the class vaccineff_data with vaccineff data.

date_interval

If NULL, the function calculates the coverage interval based on the min() and max() of the vacc_date_col. It is also possible to pass a custom date interval to truncate or expand the date interval (see example).

cumulative

If TRUE, returns the cumulative number of doses over the time window.

Value

2-axis ggplot2 plot of vaccine coverage and daily doses.


Plot Log-Log Test for Proportional Hazards Hypothesis

Description

This function uses the return from the Cox model to create a log-log plot.

Usage

plot_loglog(cox_model_prediction)

Arguments

cox_model_prediction

Prediction from Cox model.

Value

Log-log plot.


Plot the Survival Probability Based on the Kaplan-Meier Model

Description

This function relies on the implementation of the Kaplan-Meier model from the package {survival}. It returns a plot of the Survival Probability or the Cumulative Hazard (if cumulative = TRUE). The return is a ggplot2 element of the curves with 95% C.I. It is possible to manipulate the colors, labels, legend, and most of the graphic elements.

Usage

plot_survival(km, percentage = TRUE, cumulative = FALSE)

Arguments

km

Kaplan-Meier estimation created with km_model.

percentage

If TRUE, returns probability in percentage.

cumulative

If TRUE, returns cumulative incidence

Value

{ggplot2} object with plot of survival or cumulative incidence.


Print summary of VE Results

Description

Print summary of vaccineff object.

Usage

## S3 method for class 'summary_vaccineff'
print(x, ...)

Arguments

x

Object of the class summary.vaccineff.

...

Additional arguments passed to other functions.

Value

None


Print Summary of Vaccineff Data

Description

Summarizes the results of make_vaccineff_data.

Usage

## S3 method for class 'summary_vaccineff_data'
print(x, ...)

Arguments

x

Object of the class summary.vaccineff_data.

...

Additional arguments passed to other functions.

Value

None


Rematch Step for Iterative Match

Description

This auxiliary function performs the re-matching strategy for iterate_match(). It rematches the population with status given by rematch_status and excludes the removed population with status control_status. A tryCatch validation handles errors when no matches can be generated due to the lack of treated or untreated individuals.

Usage

rematch_(
  all,
  adjusted,
  outcome_date_col,
  censoring_date_col,
  immunization_date_col,
  removed_i,
  vacc_status_col,
  rematch_status,
  control_status,
  nearest,
  exact,
  start_cohort,
  end_cohort,
  im
)

Arguments

all

data.frame with the entire cohort.

adjusted

data.frame with the adjusted cohort to calculate removed cases. Default is NULL, which returns 0.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

immunization_date_col

Name of the column that contains the immunization date to set the beginning of the follow-up period (t0_follow_up).

vacc_status_col

Name of the column containing the vaccination.

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers).

exact

Name(s) of column(s) for exact matching

start_cohort

Start date of the study.

end_cohort

End date of the study.

im

Iteration number for error message

Value

List that contains three data.frame: adjusted: updated adjusted matches adjusted_i_s: new adjusted matches for rematch_status matched_i_s: all the new matches for rematch_status


Create Status Column

Description

This function generates a binary status column using the set of columns passed through the variable col_names. This column must contain the information of the outcomes or the vaccine dates. It generates a logical condition using the operators & or |, and evaluates if the registers in the columns contain or not information. If the logical operator is &, the function returns a success only if all the columns contain information. On the other hand, if the logical operator is |, it is enough to find one column with information indicating success. It is recommended to use this method when working with several outcomes or several vaccine doses. By default, it returns a binary column where 0 means no outcome or no vaccine and 1 means the opposite. However, it can also receive custom options, e.g., c("v", "u") for vaccinated and unvaccinated.

Usage

set_status(data_set, col_names, operator = c("&", "|"), status = c(1, 0))

Arguments

data_set

data.frame with at least one column from which to generate the status specified in status.

col_names

Name(s) of the column(s) as a string or a character vector containing the information from which the status is calculated.

operator

A single logical operator to evaluate the condition.

status

A two-element vector specifying the values to be assigned that indicate whether the individual is vaccinated or not, e.g., c("v","u"). The first element of the vector must be the status when the condition is satisfied, i.e., vaccinated, while the second element is the value indicating that the individual is not vaccinated.

Value

Status


Static Matching

Description

This function calls match_cohort_ once and then removes the pairs whose exposure times do not coincide. It returns the adjusted cohort, a summary of the matching result, and the balance of the cohort before and after matching.

Usage

static_match(
  data_set,
  outcome_date_col,
  censoring_date_col,
  immunization_date_col,
  vacc_status_col,
  vaccinated_status,
  unvaccinated_status,
  start_cohort,
  end_cohort,
  nearest,
  exact
)

Arguments

data_set

data.frame with cohort information.

outcome_date_col

Name of the column that contains the outcome dates.

censoring_date_col

Name of the column that contains the censoring date.

immunization_date_col

Name of the column that contains the immunization date to set the beginning of the follow-up period (t0_follow_up).

vacc_status_col

Name of the column containing the vaccination.

vaccinated_status

Status assigned to the vaccinated population.

unvaccinated_status

Status assigned to the unvaccinated population.

start_cohort

Start date of the study.

end_cohort

End date of the study.

nearest

Named vector with name(s) of column(s) for nearest matching and caliper(s) for each variable (e.g., nearest = c("characteristic1" = n1, "characteristic2" = n2), where n1 and n2 are the calipers).

exact

Name(s) of column(s) for exact matching

Value

List with results from static match: match: adjusted cohort, summary: matching summary, balance_all: balance of the cohort before matching, balance_matched: balance of the cohort after matching.


Summarize VE Results

Description

Summarizes the results of vaccineff.

Usage

## S3 method for class 'vaccineff'
summary(object, ...)

Arguments

object

Object of the class vaccineff.

...

Additional arguments passed to other functions.

Value

Summary of the results from estimate_vaccineff.


Summarize Vaccineff Data

Description

Summarizes the results of make_vaccineff_data.

Usage

## S3 method for class 'vaccineff_data'
summary(object, warnings_log = FALSE, ...)

Arguments

object

Object of the class vaccineff_data.

warnings_log

If TRUE, prints the warnings log.

...

Additional arguments passed to other functions.

Value

Summary of the results from vaccineff data


Internal function to truncate data based on start_cohort

Description

Internal function to truncate data based on start_cohort

Usage

truncate_from_start_cohort(
  data_set,
  outcome_date_col,
  censoring_date_col,
  start_cohort
)

Arguments

data_set

data.frame with cohort information.

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.

Value

data.frame with truncated data

mirror server hosted at Truenetwork, Russian Federation.