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 |
Data from
cohortdata
cohortdata
An object of class "cross"
; see read.cross
.
cohortdata
cohortdata
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.
estimate_vaccineff(vaccineff_data, at)
estimate_vaccineff(vaccineff_data, at)
vaccineff_data |
Object of the class |
at |
Number of days at which VE is estimated from the beginning of the follow-up period. |
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
# 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)
# 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)
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.
get_age_group(data_set, col_age, max_val, min_val = 0, step)
get_age_group(data_set, col_age, max_val, min_val = 0, step)
data_set |
|
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 |
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
.
# 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)
# 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)
vaccineff_data
ObjectThis function constructs an S3 object of the class
vaccineff_data
that contains all the relevant information for the study.
to estimate the effectiveness.
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 )
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 )
data_set |
|
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 |
vaccinated_status |
Status assigned to the vaccinated population.
Default is |
unvaccinated_status |
Status assigned to the unvaccinated population.
Default is |
immunization_delay |
Characteristic time in days before the patient is considered immune. Default is 0. |
end_cohort |
End date of the study. |
match |
|
exact |
Name(s) of column(s) for |
nearest |
Named vector with name(s) of column(s) for |
take_first |
|
t0_follow_up |
Column with the initial dates of the follow-up period.
This column is only used if |
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.
# 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)
# 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)
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.
plot_coverage(vaccineff_data, date_interval = NULL, cumulative = FALSE)
plot_coverage(vaccineff_data, date_interval = NULL, cumulative = FALSE)
vaccineff_data |
Object of the class |
date_interval |
If NULL, the function calculates the coverage interval
based on the min() and max() of the |
cumulative |
If |
2-axis ggplot2 plot of vaccine coverage and daily doses.
# 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 )
# 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 )
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
).
## S3 method for class 'vaccineff' plot( x, type = c("loglog", "surv"), cumulative = FALSE, percentage = FALSE, ... )
## S3 method for class 'vaccineff' plot( x, type = c("loglog", "surv"), cumulative = FALSE, percentage = FALSE, ... )
x |
Object of class |
type |
Type of plot. Options are |
cumulative |
If |
percentage |
If |
... |
Additional arguments passed to other functions. |
Plot extracted from vaccineff
.
Summarizes the results of match_cohort
.
## S3 method for class 'match' summary(object, ...)
## S3 method for class 'match' summary(object, ...)
object |
Object of the class |
... |
Additional arguments passed to other functions. |
Summary of the results from matching.
Summarizes the results of vaccineff
.
## S3 method for class 'vaccineff' summary(object, ...)
## S3 method for class 'vaccineff' summary(object, ...)
object |
Object of the class |
... |
Additional arguments passed to other functions. |
Summary of the results from estimate_vaccineff
.
Summarizes the results of make_vaccineff_data
.
## S3 method for class 'vaccineff_data' summary(object, warnings_log = FALSE, ...)
## S3 method for class 'vaccineff_data' summary(object, warnings_log = FALSE, ...)
object |
Object of the class |
warnings_log |
If |
... |
Additional arguments passed to other functions. |
Summary of the results from vaccineff data