Skip to content

Commit

Permalink
finish over-reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
erblast committed Feb 28, 2024
1 parent ae94573 commit a0b91d6
Show file tree
Hide file tree
Showing 108 changed files with 1,450 additions and 612 deletions.
16 changes: 11 additions & 5 deletions R/S3_simaerep.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ validate_simaerep <- function(x) {
#' Default: list(method = "med75_adj", min_pat_pool = 0.2)
#'@param param_sim_sites list of parameters passed to [sim_sites()][sim_sites],
#' Default: list(r = 1000, poisson_test = FALSE, prob_lower = TRUE)
#'@param under_only compute under-reporting probabilities only, default = TRUE
#'@param param_eval_sites list of parameters passed to
#' [eval_sites()][eval_sites], Default: list(method = "BH")
#'@param progress logical, display progress bar, Default = TRUE
Expand All @@ -67,6 +66,9 @@ validate_simaerep <- function(x) {
#' sets. Default: TRUE
#'@param env optional, provide environment of original visit data, Default:
#' parent.frame()
#'@param under_only, logical compute under-reporting probabilities only,
#' superseeds under_only parameter passed to [eval_sites()][eval_sites] and
#' [sim_sites()][sim_sites], Default: TRUE
#'@return simaerep object
#'@details executes [site_aggr()][site_aggr], [sim_sites()][sim_sites] and
#' [eval_sites()][eval_sites] on original visit data and stores all
Expand All @@ -90,7 +92,8 @@ validate_simaerep <- function(x) {
#' str(aerep)
#'
#'@seealso [site_aggr()][site_aggr], [sim_sites()][sim_sites],
#' [eval_sites()][eval_sites], [orivisit()][orivisit], [plot.simaerep()][plot.simaerep]
#' [eval_sites()][eval_sites], [orivisit()][orivisit],
#' [plot.simaerep()][plot.simaerep]
#'@rdname simaerep
#'@export
simaerep <- function(df_visit,
Expand All @@ -101,15 +104,15 @@ simaerep <- function(df_visit,
param_sim_sites = list(
r = 1000,
poisson_test = FALSE,
prob_lower = TRUE,
under_only = TRUE
prob_lower = TRUE
),
param_eval_sites = list(
method = "BH"
),
progress = TRUE,
check = TRUE,
env = parent.frame()) {
env = parent.frame(),
under_only = TRUE) {

call <- rlang::enexpr(df_visit)

Expand All @@ -119,6 +122,9 @@ simaerep <- function(df_visit,
df_visit <- check_df_visit(df_visit)
}

param_sim_sites$under_only <- under_only
param_eval_sites$under_only <- under_only

df_site <- do.call(
site_aggr,
c(
Expand Down
3 changes: 2 additions & 1 deletion R/simaerep.R
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ get_visit_med75 <- function(df_pat,
#' @param df_sim_sites dataframe generated by \code{\link[simaerep]{sim_sites}}
#' @param method character, passed to stats::p.adjust(), if NULL
#' eval_sites_deprecated() is used instead, Default = "BH"
#' @inheritParams sim_sites
#' @param ... use to pass r_sim_sites parameter to eval_sites_deprecated()
#' @return dataframe with the following columns:
#' \describe{
Expand Down Expand Up @@ -410,7 +411,7 @@ eval_sites <- function(df_sim_sites,

if (! under_only) {
df_out <- df_out %>%
mutate(prob_high = 1 - prob_low) %>%
mutate(prob_high = 1 - .data$prob_low) %>%
arrange(.data$study_id, .data$prob_high) %>%
mutate(
prob_high_adj = p.adjust(.data$prob_high, method = method),
Expand Down
1 change: 1 addition & 0 deletions R/simaerep_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ get_legend <- function(p) {
#' @param study study
#' @param n_sites integer number of most at risk sites, Default: 16
#' @param pval logical show p-value, Default:FALSE
#' @param prob_col character, denotes probability column, Default: "prob_low_prob_ur"
#' @return ggplot
#' @details Left panel shows mean AE reporting per site (lightblue and darkblue
#' lines) against mean AE reporting of the entire study (golden line). Single
Expand Down
6 changes: 4 additions & 2 deletions R/simulate_test_data.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#' @title simulate study test data
#' @description evenly distributes a number of given patients across a number of
#' given sites. Then simulates ae development of each patient reducing the
#' number of reported AEs for patients distributed to AE-under-reporting sites.
#' number of reported AEs for patients distributed to AE-under-reporting
#' sites.
#' @param n_pat integer, number of patients, Default: 1000
#' @param n_sites integer, number of sites, Default: 20
#' @param frac_site_with_ur fraction of AE under-reporting sites, Default: 0
#' @param ur_rate AE under-reporting rate, will lower mean ae per visit used to
#' simulate patients at sites flagged as AE-under-reporting., Default: 0
#' simulate patients at sites flagged as AE-under-reporting. Negative Values
#' will simulate over-reporting., Default: 0
#' @param max_visit_mean mean of the maximum number of visits of each patient,
#' Default: 20
#' @param max_visit_sd standard deviation of maximum number of visits of each
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ articles:
- check_poisson
- visits_or_days
- gsm_perf
- over

reference:
- title: S3 Interface
Expand Down
4 changes: 2 additions & 2 deletions data-raw/generate_test_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ df_visit_test <- dplyr::bind_rows(df_visit1, df_visit2)

df_site_test <- site_aggr(df_visit_test)

df_sim_sites_test <- sim_sites(df_site_test, df_visit, r = 100)
df_sim_sites_test <- sim_sites(df_site_test, df_visit_test, r = 100)

df_eval_test <- eval_sites(df_sim_sites_test)

Expand All @@ -35,7 +35,7 @@ visit_test <- orivisit(df_visit_test)

# portfolio performance

df_site_max_test <- df_visit %>%
df_site_max_test <- df_visit_test %>%
group_by(study_id, site_number, patnum) %>%
summarise(max_visit = max(visit),
max_ae = max(n_ae),
Expand Down
5 changes: 4 additions & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a0b91d6

Please sign in to comment.