sim_studies {simaerep}R Documentation

Simulate studies.

Description

Test function, test applicability of poisson test, by calculating a the bootstrapped probability of obtaining a specific p-value or lower, use in combination with get_ecd_values().

Usage

sim_studies(
  df_visit,
  df_site,
  r = 100,
  poisson_test = TRUE,
  prob_lower = TRUE,
  r_prob_lower = 1000,
  under_only = TRUE,
  parallel = FALSE,
  keep_ae = FALSE,
  min_n_pat_with_med75 = 1,
  studies = NULL,
  .progress = TRUE
)

Arguments

df_visit

dataframe

df_site

dataframe

r

integer, denotes number of simulations, Default: 1000

poisson_test

logical, calculates poisson.test pvalue, Default: TRUE

prob_lower

logical, calculates probability for getting a lower value, Default: FALSE

r_prob_lower

integer, denotes number of simulations for prob_lower value calculation,, Default: 1000

under_only

compute under-reporting probabilities only, default = TRUE

parallel

logical, see examples for registering parallel processing framework , Default: FALSE

keep_ae

logical, keep ae numbers in output dataframe memory increase roughly 30 percent, Default: F

min_n_pat_with_med75

integer, min number of patients with med75 at site to simulate, Default: 1

studies

vector with study names, Default: NULL

.progress

logical, show progress bar

Details

Here we simulate study replicates maintaining the same number of sites, patients and visit_med75 by bootstrap resampling, then probabilities for obtaining lower or same mean_ae count and p-values using poisson.test are calculated.

adds column with simulated probabilities for equal or lower mean_ae at visit_med75

Value

dataframe

Examples


df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 5,
                                      frac_site_with_ur = 0.4, ur_rate = 0.6)

df_visit1$study_id <- "A"

df_visit2 <- sim_test_data_study(n_pat = 1000, n_sites = 3,
                                      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 <- site_aggr(df_visit)

sim_studies(df_visit, df_site, r = 3, keep_ae = TRUE)

## Not run: 
# parallel processing -------------------------
library(future)
future::plan(multiprocess)
sim_studies(df_visit, df_site, r = 3, keep_ae = TRUE, parallel = TRUE)
future::plan(sequential)

## End(Not run)

[Package simaerep version 0.5.0 Index]