View source: R/convert_raw_to_contin_tab.R
convert_raw_to_contin_table | R Documentation |
Convert raw AE-Drug incidence data into a contingency table
convert_raw_to_contin_table( rawdata, Drug_col_name = "DRUG", AE_col_name = "AE", id_col_name = "CASEID", count_col_name = "COUNT", aggregated = FALSE, create_other_Drug_col = FALSE, other_Drug_excludes = NULL, other_Drug_colname = "Other_Drug", create_other_AE_row = FALSE, other_AE_excludes = NULL, other_AE_rowname = "Other_AE", ... )
rawdata |
a |
Drug_col_name, AE_col_name, id_col_name, count_col_name |
Drug, AE, case id and count
column names in |
aggregated |
logical. Has the incidences been already aggregated/summarized into counts
in |
create_other_Drug_col |
logical. Add a column in the contingency table for "Other Drugs"? This column plays the role of a "baseline" group of drugs that typically do not indicate an adverse event association with the signal of interest. Care should be taken while determining which drugs to include in this group; See Ding et al (2020) for guidance. |
other_Drug_excludes |
character vector cataloging Drugs that are NOT to be included in the
column for Other Drugs. If NULL (default) then then no Drugs are included in Other Drugs (i.e.,
|
other_Drug_colname |
character. Row name for the "Other Drug" column created. Ignored if
|
create_other_AE_row |
logical. Add a row in the contingency table for "Other AEs"? This can aid computation
in situations where there are certain AEs of primary interest. See |
other_AE_excludes |
character vector cataloging AEs that are NOT to be included in the
row for Other AEs. If NULL (default) then then no AEs are included in Other AEs (i.e.,
|
other_AE_rowname |
character. Row name for the "Other AE" row created. Defaults to "Other AE". Ignored if
|
... |
unused. |
This is a convenience function that creates a contingency table cataloging counts of AE-Drug incidences from a raw Drug/AE incidence data frame. It accepts both raw incidence data (each row is one incidence of a Drug-AE combination, indexed by case ids) and summarized count data (each row catalogs the total counts of incidences of each Drug-AE pair). The output is a matrix (contingency table) enumerating total count of cases for each pair of AE (along the rows) and drug (along the columns) with appropriately specified row and column names, and can be passed to a pvlrt() call. See the examples for more details.
The output can be fed into pvlrt or its wrappers as contin_table
Ding, Y., Markatou, M. and Ball, R., 2020. An evaluation of statistical approaches to postmarketing surveillance. Statistics in Medicine, 39(7), pp.845-874.
Chakraborty, S., Liu, A., Ball, R. and Markatou, M., 2022. On the use of the likelihood ratio test methodology in pharmacovigilance. Statistics in Medicine, 41(27), pp.5395-5420.
# convert to contingency table form incidence (non-aggregated) raw data # AE subset = AEs in statin46 # Durg subset = union of statin46 and gbca drugs tab1 <- convert_raw_to_contin_table( rawdata = faers22q3raw, Drug_col_name = "DRUG", AE_col_name = "AE", id_col_name = "CASEID", aggregated = FALSE, other_AE_excludes = rownames(statin46), other_Drug_excludes = union(colnames(gbca), colnames(statin)), create_other_Drug_col = TRUE, create_other_AE_row = FALSE ) # convert to contingency table AFTER aggregating and counting # the total number of incidences of each (AE, Drug) pair ## Same AE and Drug subsets as before ## aggregation (counting) done using data.table dt[i, j, by] syntax ## uses magrittr %>% pipe tab2 <- data.table::as.data.table( faers22q3raw )[ , .(COUNT = length(unique(CASEID))), by = .(DRUG, AE) ] %>% convert_raw_to_contin_table( Drug_col_name = "DRUG", AE_col_name = "AE", count_col_name = "COUNT", aggregated = TRUE, other_AE_excludes = rownames(statin46), other_Drug_excludes = union(colnames(gbca), colnames(statin)), create_other_Drug_col = TRUE, create_other_AE_row = FALSE ) all.equal(tab1, tab2) # use the contingency table produced above in pvlrt() ## 500 bootstrap iterations (nsim) in the example below ## is for quick demonstration only -- ## we recommended setting nsim to 10000 (default) or bigger test1 <- pvlrt(tab1, nsim = 500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.