# 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)
Run the code above in your browser using DataLab