construct_cohort_vac_outcome.RdConstruct a cohort-vaccination-event data frame
construct_cohort_vac_outcome(
cohort,
vacs,
outcome = NULL,
start_date = "2020-12-26",
end_date = as.character(Sys.Date()),
incident_cases = FALSE,
washout = 0,
pid_column = "HETU_ID",
birthdate_column = "SYNTYMAPAIVA",
deathdate_column = "KUOLINPVM",
followupstart_column = "SYNTYMAPAIVA",
followupend_column = "KUOLINPVM",
vacdate_column = "RECORDDATE",
vaclabel_column = "PRODUCT_ID",
outcomedate_column = "TAPAHTUMAPVM"
)Individuals of interest. E.g. data read by read_vaesto(): A data frame with columns HETU_ID, SYNTYMAPAIVA, KUOLINPVM. Optionally can include columns for individual followup start and end; the birth and death dates are used by default. See details. Other included columns are kept in the results The required columns can be named differently, see the arguments _column.
Vaccination data for the cohort, will be coerced to wide format in terms of doses. Must include columns "HETU_ID", "RECORDATE", "PRODUCT_ID". Can also include column 'cumdose', or 'CUMDOSE' (the cumulative dose indicator) if not, it will be computed. The required columns can be named differently, see the arguments _column.
Outcome event data for a single outcome of interest. Must include columns "HETU_ID" "TAPAHTUMAPVM". The required columns can be named differently, see the arguments _column. This can be NULL, for constructing follow-up with no events.
A Date or ISO standard character for a date. General start of follow-up for the cohort. The cohort is restricted to those alive or born after the start_date
A Date or ISO standard character for a date. General end of follow-up for the cohort. Events occuring after this date are excluded and individuals born after this date are excluded.
If TRUE, individuals with outcomes before 'start_date' are excluded from the cohort. Default is FALSE.
An integer defining the length of the washout period in days after an event. The assumption is that the outcomes data already implements this washout period, no filtering based on this choice is done, but an error is thrown if the outcomes data has events which are closer to each other than washout. Default is 0 (no washout). Can be Inf (incident cases).
Length one character giving the column name of the personal identifier, common to each dataset. Default is "HETU_ID".
Length one character giving the column name of the birth date column in 'cohort'. Default "SYNTYMAPAIVA",
Length one character giving the column name of the death date column in 'cohort'. Default "KUOLINPVM",
Length one character giving the column name of the individual follow-up start date column on 'cohort'. Default "SYNTYMAPAIVA",
Length one character giving the column name of the individual follow-up end date column in 'cohort'. Default "KUOLINPVM",
Length one character giving the column name of the vaccination date column in 'vacs'. Default "RECORDDATE",
Length one character giving the column name of the vaccination label column in 'vacs'. Default "PRODUCT_ID",
Length one character giving the column name of the outcome date column in 'outcome'. Default "TAPAHTUMAPVM"
All of the required columns are renamed to the default values specified in the argument documentation
Adds columns 'entrypvm' and 'exitpvm' to the resulting data. The former is the (parallel) maximum of the general follow-up start date and the individual followup start date, and the latter is the (parallel) minimum of the general followup end date, and the individual followup end date.
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")