Simulate visit level data from a portfolio configuration.
Arguments
- df_config
dataframe as returned by
get_portf_config
- df_event_rates
dataframe with event rates. Default: NULL
- progress
logical, Default: TRUE
- parallel
logical activate parallel processing, see details, Default: FALSE
Value
dataframe with the following columns:
- study_id
study identification
- event_per_visit_mean
mean event per visit per study
- site_id
site
- max_visit_sd
standard deviation of maximum patient visits per site
- max_visit_mean
mean of maximum patient visits per site
- patient_id
number of patients
- visit
visit number
- n_event
cumulative sum of events
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)
See also
sim_test_data_study
get_portf_config
sim_test_data_portfolio
Examples
# \donttest{
df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 10,
ratio_out = 0.4, factor_event_rate = 0.6,
study_id = "A")
df_visit2 <- sim_test_data_study(n_pat = 100, n_sites = 10,
ratio_out = 0.2, factor_event_rate = 0.1,
study_id = "B")
df_visit <- dplyr::bind_rows(df_visit1, df_visit2)
df_config <- get_portf_config(df_visit)
df_config
#> # A tibble: 20 × 6
#> study_id event_per_visit_mean site_id max_visit_sd max_visit_mean n_pat
#> <chr> <dbl> <chr> <dbl> <dbl> <int>
#> 1 0001 0.778 0001 3.08 20.8 10
#> 2 0001 0.778 0002 3.39 20.8 10
#> 3 0001 0.778 0003 4.93 19.5 10
#> 4 0001 0.778 0004 3.43 19.3 10
#> 5 0001 0.778 0005 4.50 19.5 10
#> 6 0001 0.778 0006 3.92 17.3 10
#> 7 0001 0.778 0007 4.76 19.7 10
#> 8 0001 0.778 0008 4.40 19.3 10
#> 9 0001 0.778 0009 4.27 19.3 10
#> 10 0001 0.778 0010 2.99 20.4 10
#> 11 0002 0.632 0001 4.30 19.7 10
#> 12 0002 0.632 0002 2.49 19.8 10
#> 13 0002 0.632 0003 5.32 19.4 10
#> 14 0002 0.632 0004 3.77 19.3 10
#> 15 0002 0.632 0005 5.44 19.7 10
#> 16 0002 0.632 0006 4.72 19.5 10
#> 17 0002 0.632 0007 4.10 20.8 10
#> 18 0002 0.632 0008 3.88 17.8 10
#> 19 0002 0.632 0009 3.89 18.3 10
#> 20 0002 0.632 0010 3.19 17.8 10
df_portf <- sim_test_data_portfolio(df_config)
df_portf
#> # A tibble: 3,725 × 8
#> study_id event_per_visit_mean site_id max_visit_sd max_visit_mean patient_id
#> <chr> <dbl> <chr> <dbl> <dbl> <chr>
#> 1 0001 0.778 0001 3.08 20.8 0001
#> 2 0001 0.778 0001 3.08 20.8 0001
#> 3 0001 0.778 0001 3.08 20.8 0001
#> 4 0001 0.778 0001 3.08 20.8 0001
#> 5 0001 0.778 0001 3.08 20.8 0001
#> 6 0001 0.778 0001 3.08 20.8 0001
#> 7 0001 0.778 0001 3.08 20.8 0001
#> 8 0001 0.778 0001 3.08 20.8 0001
#> 9 0001 0.778 0001 3.08 20.8 0001
#> 10 0001 0.778 0001 3.08 20.8 0001
#> # ℹ 3,715 more rows
#> # ℹ 2 more variables: visit <int>, n_event <dbl>
# }