sim_ur_scenarios {simaerep} | R Documentation |
Simulate Under-Reporting Scenarios
Description
Use with simulated portfolio data to generate under-reporting stats for specified scenarios.
Usage
sim_ur_scenarios(
df_portf,
extra_ur_sites = 3,
ur_rate = c(0.25, 0.5),
r = 1000,
poisson_test = FALSE,
prob_lower = TRUE,
parallel = FALSE,
progress = TRUE,
site_aggr_args = list(),
eval_sites_args = list()
)
Arguments
df_portf |
dataframe as returned by |
extra_ur_sites |
numeric, set maximum number of additional under-reporting sites, see details Default: 3 |
ur_rate |
numeric vector, set under-reporting rates for scenarios Default: c(0.25, 0.5) |
r |
integer, denotes number of simulations, default = 1000 |
poisson_test |
logical, calculates poisson.test pvalue |
prob_lower |
logical, calculates probability for getting a lower value |
parallel |
logical, use parallel processing see details, Default: FALSE |
progress |
logical, show progress bar, Default: TRUE |
site_aggr_args |
named list of parameters passed to
|
eval_sites_args |
named list of parameters passed to
|
Details
The function will apply under-reporting scenarios to each site. Reducing the number of AEs by a given under-reporting (ur_rate) for all patients at the site and add the corresponding under-reporting statistics. Since the under-reporting probability is also affected by the number of other sites that are under-reporting we additionally calculate under-reporting statistics in a scenario where additional under reporting sites are present. For this we use the median number of patients per site at the study to calculate the final number of patients for which we lower the AEs in a given under-reporting scenario. We use the furrr package to implement parallel processing as these simulations can take a long time to run. For this to work we need to specify the plan for how the code should run, e.g. plan(multisession, workers = 18)
Value
dataframe with the following columns:
- study_id
study identification
- site_number
site identification
- n_pat
number of patients at site
- n_pat_with_med75
number of patients at site with visit_med75
- visit_med75
median(max(visit)) * 0.75
- mean_ae_site_med75
mean AE at visit_med75 site level
- mean_ae_study_med75
mean AE at visit_med75 study level
- n_pat_with_med75_study
number of patients at site with visit_med75 at study excl site
- extra_ur_sites
additional sites with under-reporting patients
- frac_pat_with_ur
ratio of patients in study that are under-reporting
- ur_rate
under-reporting rate
- pval
p-value as returned by
poisson.test
- prob_low
bootstrapped probability for having mean_ae_site_med75 or lower
- pval_adj
adjusted p-values
- prob_low_adj
adjusted bootstrapped probability for having mean_ae_site_med75 or lower
- pval_prob_ur
probability under-reporting as 1 - pval_adj, poisson.test (use as benchmark)
- prob_low_prob_ur
probability under-reporting as 1 - prob_low_adj, bootstrapped (use)
See Also
sim_test_data_study
get_config
sim_test_data_portfolio
sim_ur_scenarios
get_portf_perf
Examples
df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 10,
frac_site_with_ur = 0.4, ur_rate = 0.6)
df_visit1$study_id <- "A"
df_visit2 <- sim_test_data_study(n_pat = 100, n_sites = 10,
frac_site_with_ur = 0.2, ur_rate = 0.1)
df_visit2$study_id <- "B"
df_visit <- dplyr::bind_rows(df_visit1, df_visit2)
df_site_max <- df_visit %>%
dplyr::group_by(study_id, site_number, patnum) %>%
dplyr::summarise(max_visit = max(visit),
max_ae = max(n_ae),
.groups = "drop")
df_config <- get_config(df_site_max)
df_config
df_portf <- sim_test_data_portfolio(df_config)
df_portf
df_scen <- sim_ur_scenarios(df_portf,
extra_ur_sites = 2,
ur_rate = c(0.5, 1))
df_scen
df_perf <- get_portf_perf(df_scen)
df_perf