sim_test_data_portfolio {simaerep} | R Documentation |
Simulate Portfolio Test Data
Description
Simulate visit level data from a portfolio configuration.
Usage
sim_test_data_portfolio(
df_config,
df_ae_rates = NULL,
parallel = FALSE,
progress = TRUE
)
Arguments
df_config |
dataframe as returned by |
df_ae_rates |
dataframe with ae rates. Default: NULL |
parallel |
logical activate parallel processing, see details, Default: FALSE |
progress |
logical, Default: TRUE |
Details
uses sim_test_data_study
.
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 = 3)
Value
dataframe with the following columns:
- study_id
study identification
- ae_per_visit_mean
mean AE per visit per study
- site_number
site
- max_visit_sd
standard deviation of maximum patient visits per site
- max_visit_mean
mean of maximum patient visits per site
- patnum
number of patients
- visit
visit number
- n_ae
cumulative sum of AEs
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