Collects the number of AEs of all eligible patients that meet visit_med75 criteria of site. Then calculates poisson.test pvalue and bootstrapped probability of having a lower mean value.
sim_sites(
df_site,
df_visit,
r = 1000,
poisson_test = TRUE,
prob_lower = TRUE,
progress = TRUE,
check = TRUE
)
dataframe created by site_aggr
dataframe, created by sim_sites
integer, denotes number of simulations, default = 1000
logical, calculates poisson.test pvalue
logical, calculates probability for getting a lower value
logical, display progress bar, Default = TRUE
logical, perform data check and attempt repair with check_df_visit(), computationally expensive on large data sets. Default: TRUE
dataframe with the following columns:
study identification
site identification
number of patients at site
median(max(visit)) * 0.75
number of patients at site with med75
mean AE at visit_med75 site level
mean AE at visit_med75 study level
number of patients at study with med75 excl. site
p-value as returned by poisson.test
bootstrapped probability for having mean_ae_site_med75 or lower
sim_sites
,
site_aggr
,
pat_pool
,
prob_lower_site_ae_vs_study_ae
,
poiss_test_site_ae_vs_study_ae
,
sim_sites
,
prep_for_sim
df_visit <- sim_test_data_study(
n_pat = 100,
n_sites = 5,
frac_site_with_ur = 0.4,
ur_rate = 0.2
)
df_visit$study_id <- "A"
df_site <- site_aggr(df_visit)
df_sim_sites <- sim_sites(df_site, df_visit, r = 100)
df_sim_sites %>%
knitr::kable(digits = 2)
#>
#>
#> |study_id |site_number | n_pat| n_pat_with_med75| visit_med75| mean_ae_site_med75| mean_ae_study_med75| n_pat_with_med75_study| pval| prob_low|
#> |:--------|:-----------|-----:|----------------:|-----------:|------------------:|-------------------:|----------------------:|----:|--------:|
#> |A |S0001 | 20| 19| 15| 6.63| 7.07| 71| 0.56| 0.26|
#> |A |S0002 | 20| 18| 15| 6.11| 7.19| 72| 0.12| 0.10|
#> |A |S0003 | 20| 17| 16| 8.53| 7.17| 66| 1.00| 1.00|
#> |A |S0004 | 20| 20| 15| 6.40| 7.14| 70| 0.29| 0.14|
#> |A |S0005 | 20| 16| 16| 8.38| 7.22| 67| 1.00| 1.00|