construct_cohort_followup.RdCreate long followup data based on cohort vaccination outcome data
construct_cohort_followup(
x,
vac1_effect = 0,
vac2_effect = 0,
vac3_effect = 0,
n = NULL,
agecuts = c(0, 12, 20, 30, 40, 50, 60, 70, 80, Inf),
datecuts = seq(from = attr(x, "start_date"), to = attr(x, "end_date"), by = "month"),
start_date = attr(x, "start_date"),
end_date = attr(x, "end_date"),
washout = attr(x, "washout"),
max_events = attr(x, "max_events"),
exclude_washout = TRUE,
risk_effect = 0,
vac_effects = NULL
)A dataset returned by construct_cohort_vac_outcome(). Required columns are: "HETU_ID", "SYNTYMAPAIVA", "entrypvm","exitpvm" and "TAPAHTUMAPVM" (event date) or multiple event date columns as 'TAPAHTUMA_1', "TAPAHTUMA_2", ... Vaccination information is not mandatory but if given must be given as RECORDDATE_1, _2, _3 and vaccine product information in PRODUCT_ID_1, _2, _3. Note that the product id can be any character instead of an integer. The data can also have attributes 'start_date', 'end_date', 'washout' and 'max_events', see the corresponding arguments.
An integer vector which defines how to split the follow-up in relation to the first covid vaccination. For example, can be 21 for vaccine effectiveness analyses or c(0, 28) for vaccine safety analyses. The cut points implied by this vector are left closed and right open. E.g. c(0,28) implies intervals 0-27, 28-Inf. Can also include negative values
An integer vector which defines how to split the follow-up in relation to the second covid vaccination. For example, can be 7 for vaccine effectiveness analyses or c(0, 28) for vaccine safety analyses. The cut points implied by this vector are left closed and right open. E.g. c(0,28) implies intervals 0-27, 28-Inf. Can also include negative values.
An integer vector of length 1 or 2 which defines how to split the follow-up in relation to the third covid vaccination. The cut points implied by this vector are left closed and right open. E.g. c(0,28) implies intervals 0-27, 28-Inf. Can also include negative values.
An integer of length one. An optional integer for choosing a random sample of n individuals from the input data. This is useful for testing as the processing can be very slow and memory intensive for a big data set.
Age is grouped according to these cutpoints. Cutpoints are left-inclusive and right exclusive.
A vector of dates. if not NULL, will split the followup according to these dates and adds a variable CALENDAR to the output, which labels dates according to these splits.
A date. Start date of follow-up. Default is taken from the input object 'start_date' attribute.
A Date. End date of follow-up. Default is taken from the input object 'end_date' attribute.
An interger of length one. The number of days after each event to consider as the washout period. The washout period starts at the day after the event date and ends washout days later. Can be Inf, which corresponds to incident cases.
An integer of length one. The maximum number of events to consider. Can not be larger than the number of TAPAHTUMA_x columns in input data, but can be smaller in which case the events included in the columns where x > max_events are ignored.
Boolean. If TRUE (default) all washout time periods are filtered out of the resulting data.
The followup can be split according to an additional time-dependent exposure. Similarily to vac1_effect, this parameter controls how that splitting is done. If specified, the input x must contain a column named RISK_EXPOSURE_DATE, which specifies the date of the time-dependent exposure. The output will contain a column RISK_EFFECT, which has a similar format to the vaccination risk intervals
A list of integer vectors for follow-up splitting with a custom number of vaccinations. If not NULL, overwrites any arguments for vac1_effect, vac2_effect and vac3_effect. Each element i of the list is considered as the split definitions for the ith dose. E.g. for a list with length n, the first element defines splits for first dose, second element defines them for the second dose, ... and nth element defines them for the nth dose. The list elements can take values with same criteria as the arguments vac1_effect, vac2_effect and vac3_effect.
A data.frame with the following columns:
LEX_ID: HETU_ID as a factor.
CALENDAR: If datecuts are given, the first date of each calendar period.
DATE: The date at which the current follow-up state starts (Date).
IKAVUOSI: Age in years at DATE.
SYNTYMAPAIVA: Birth date (Date).
KUOLINPVM: Date of death (Date).
PERSONDAYS: Duration in days of the current follow-up state starting at DATE.
VACCINE_EFFECT: Label for the current follow-up state derived from
vac_effects (or vac1_effect, vac2_effect, vac3_effect) and dose number.
Time before the first cutpoint is labeled "None".
Later dose effects override earlier ones.
Labels include the dose (e.g. "VAC1", "VAC2") followed by the time interval.
For example "VAC1:0-28" means days 0–27 after the first dose.
VACCINE_EFFECT_PRODUCT: Similar to VACCINE_EFFECT, but includes product
information and dose number. For example "103_2:0-28" means days 0–27
after the second dose of product 103.
VACCINE_EFFECT_PRODUCTS: Similar to VACCINE_EFFECT_PRODUCT, but includes
the cumulative product history (products separated by "+").
For example "103+103:0-28" means days 0–27 after the second dose,
when the first dose was also 103.
COVVAC_Tx: Number of days from DATE until the x-th COVID-19 dose.
EVENT_Tx: Number of days from DATE until the x-th event.
start_date <- "2020-02-01" # start of follow-up
end_date <- as.character(Sys.Date()) # end of follow-up
cohort <- data.frame(HETU_ID = c(1,2),
SYNTYMAPAIVA = c(as.Date("1982-02-04"), as.Date("1980-05-04")),
KUOLINPVM = c(NA, NA))
vacs <- data.frame(HETU_ID = c(1,1),
RECORDDATE = as.Date(c("2021-04-20", "2021-05-20")),
PRODUCT_ID = c("COV", "COV"))
outcome <- data.frame(HETU_ID = c(1,1, 2),
diagdate = as.Date(c("2021-04-25", "2021-06-25", "2021-04-02")))
cohort_vac_outcome <- construct_cohort_vac_outcome(cohort, vacs, outcome,
incident_cases = FALSE,
washout = 0,
outcomedate_column = "diagdate")
cohort_followup <- construct_cohort_followup(cohort_vac_outcome,
vac1_effect = 21,
vac2_effect = 7,
vac3_effect = 0,
washout = 180)