h_response_subgroups | R Documentation |
Helper functions that tabulate in a data frame statistics such as response rate and odds ratio for population subgroups.
h_proportion_df(rsp, arm)
h_proportion_subgroups_df(
variables,
data,
groups_lists = list(),
label_all = "All Patients"
)
h_odds_ratio_df(rsp, arm, strata_data = NULL, conf_level = 0.95, method = NULL)
h_odds_ratio_subgroups_df(
variables,
data,
groups_lists = list(),
conf_level = 0.95,
method = NULL,
label_all = "All Patients"
)
rsp |
( |
arm |
( |
variables |
(named |
data |
( |
groups_lists |
(named |
label_all |
( |
strata_data |
( |
conf_level |
( |
method |
( |
Main functionality is to prepare data for use in a layout-creating function.
h_proportion_df()
returns a data.frame
with columns arm
, n
, n_rsp
, and prop
.
h_proportion_subgroups_df()
returns a data.frame
with columns arm
, n
, n_rsp
, prop
, subgroup
,
var
, var_label
, and row_type
.
h_odds_ratio_df()
returns a data.frame
with columns arm
, n_tot
, or
, lcl
, ucl
, conf_level
, and
optionally pval
and pval_label
.
h_odds_ratio_subgroups_df()
returns a data.frame
with columns arm
, n_tot
, or
, lcl
, ucl
,
conf_level
, subgroup
, var
, var_label
, and row_type
.
h_proportion_df()
: Helper to prepare a data frame of binary responses by arm.
h_proportion_subgroups_df()
: Summarizes proportion of binary responses by arm and across subgroups
in a data frame. variables
corresponds to the names of variables found in data
, passed as a named list and
requires elements rsp
, arm
and optionally subgroups
. groups_lists
optionally specifies
groupings for subgroups
variables.
h_odds_ratio_df()
: Helper to prepare a data frame with estimates of
the odds ratio between a treatment and a control arm.
h_odds_ratio_subgroups_df()
: Summarizes estimates of the odds ratio between a treatment and a control
arm across subgroups in a data frame. variables
corresponds to the names of variables found in
data
, passed as a named list and requires elements rsp
, arm
and optionally subgroups
and strata
. groups_lists
optionally specifies groupings for subgroups
variables.
library(dplyr)
library(forcats)
adrs <- tern_ex_adrs
adrs_labels <- formatters::var_labels(adrs)
adrs_f <- adrs %>%
filter(PARAMCD == "BESRSPI") %>%
filter(ARM %in% c("A: Drug X", "B: Placebo")) %>%
droplevels() %>%
mutate(
# Reorder levels of factor to make the placebo group the reference arm.
ARM = fct_relevel(ARM, "B: Placebo"),
rsp = AVALC == "CR"
)
formatters::var_labels(adrs_f) <- c(adrs_labels, "Response")
h_proportion_df(
c(TRUE, FALSE, FALSE),
arm = factor(c("A", "A", "B"), levels = c("A", "B"))
)
h_proportion_subgroups_df(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "BMRKR2")),
data = adrs_f
)
# Define groupings for BMRKR2 levels.
h_proportion_subgroups_df(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "BMRKR2")),
data = adrs_f,
groups_lists = list(
BMRKR2 = list(
"low" = "LOW",
"low/medium" = c("LOW", "MEDIUM"),
"low/medium/high" = c("LOW", "MEDIUM", "HIGH")
)
)
)
# Unstratatified analysis.
h_odds_ratio_df(
c(TRUE, FALSE, FALSE, TRUE),
arm = factor(c("A", "A", "B", "B"), levels = c("A", "B"))
)
# Include p-value.
h_odds_ratio_df(adrs_f$rsp, adrs_f$ARM, method = "chisq")
# Stratatified analysis.
h_odds_ratio_df(
rsp = adrs_f$rsp,
arm = adrs_f$ARM,
strata_data = adrs_f[, c("STRATA1", "STRATA2")],
method = "cmh"
)
# Unstratified analysis.
h_odds_ratio_subgroups_df(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "BMRKR2")),
data = adrs_f
)
# Stratified analysis.
h_odds_ratio_subgroups_df(
variables = list(
rsp = "rsp",
arm = "ARM",
subgroups = c("SEX", "BMRKR2"),
strata = c("STRATA1", "STRATA2")
),
data = adrs_f
)
# Define groupings of BMRKR2 levels.
h_odds_ratio_subgroups_df(
variables = list(
rsp = "rsp",
arm = "ARM",
subgroups = c("SEX", "BMRKR2")
),
data = adrs_f,
groups_lists = list(
BMRKR2 = list(
"low" = "LOW",
"low/medium" = c("LOW", "MEDIUM"),
"low/medium/high" = c("LOW", "MEDIUM", "HIGH")
)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.