Package 'vaccineff'

Title: Estimate Vaccine Effectiveness Based on Different Study Designs
Description: Tools for estimating vaccine effectiveness and vaccine related metrics.
Authors: David Santiago Quevedo [aut] , Zulma M. Cucunubá [aut, cre] , International Development Research Center (IDRC) [fnd], Geraldine Gómez Millán [ctb] , Pratik Gupte [ctb] , Érika J Cantor [ctb] , Santiago Loaiza [ctb] , Jaime Pavlich-Mariscal [ctb] , Hugo Gruson [ctb] , Chris Hartgerink [ctb] , Felipe Segundo Abril [ctb]
Maintainer: Zulma M. Cucunubá <[email protected]>
License: MIT + file LICENSE
Version: 0.0.4.9000
Built: 2024-11-08 09:21:57 UTC
Source: https://github.com/epiverse-trace/vaccineff

Help Index


Cohort data on vaccineff

Description

Data from

Usage

cohortdata

Format

An object of class "cross"; see read.cross.

Examples

cohortdata

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("2044-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)

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)

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("2044-12-31"),
  match = TRUE,
  exact = c("age", "sex"),
  nearest = NULL
)

# Print summary of data
summary(vaccineff_data)

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.

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("2044-12-31"),
  match = TRUE,
  exact = c("age", "sex"),
  nearest = NULL
)
plot_coverage(vaccineff_data = vaccineff_data,
  date_interval = as.Date(c("2044-01-03", "2044-09-30")),
  cumulative = FALSE
)

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.


Summarize Matching Results

Description

Summarizes the results of match_cohort.

Usage

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

Arguments

object

Object of the class match.

...

Additional arguments passed to other functions.

Value

Summary of the results from 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