odds_ratio {junco} | R Documentation |
Odds ratio estimation
Description
Usage
a_odds_ratio_j(
df,
.var,
.df_row,
ref_path,
.spl_context,
...,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_odds_ratio_j(
df,
.var,
.ref_group,
.in_ref_col,
.df_row,
variables = list(arm = NULL, strata = NULL),
conf_level = 0.95,
groups_list = NULL,
na_if_no_events = TRUE,
method = c("exact", "approximate", "efron", "breslow", "cmh")
)
Arguments
df |
( |
.var |
( |
.df_row |
( |
ref_path |
( |
.spl_context |
( |
... |
Additional arguments passed to the statistics function. |
.stats |
( |
.formats |
( |
.labels |
( |
.indent_mods |
( |
.ref_group |
( |
.in_ref_col |
( |
variables |
( |
conf_level |
( |
groups_list |
( |
na_if_no_events |
( |
method |
( |
Value
-
a_odds_ratio_j()
returns the corresponding list with formattedrtables::CellValue()
.
-
s_odds_ratio_j()
returns a named list with the statisticsor_ci
(containingest
,lcl
, anducl
),pval
andn_tot
.
Functions
-
a_odds_ratio_j()
: Formatted analysis function which is used asafun
. Note that the junco specificref_path
and.spl_context
arguments are used for reference column information. -
s_odds_ratio_j()
: Statistics function which estimates the odds ratio between a treatment and a control. Avariables
list witharm
andstrata
variable names must be passed if a stratified analysis is required.
Note
The a_odds_ratio_j()
and s_odds_ratio_j()
functions have the _j
suffix to distinguish them
from tern::a_odds_ratio()
and tern::s_odds_ratio()
, respectively.
These functions differ as follows:
Additional
method = 'cmh'
option is provided to calculate the Cochran-Mantel-Haenszel estimate.The p-value is returned as an additional statistic.
Once these updates are contributed back to tern
, they can later be replaced by the tern
versions.
Examples
set.seed(12)
dta <- data.frame(
rsp = sample(c(TRUE, FALSE), 100, TRUE),
grp = factor(rep(c("A", "B"), each = 50), levels = c("A", "B")),
strata = factor(sample(c("C", "D"), 100, TRUE))
)
a_odds_ratio_j(
df = subset(dta, grp == "A"),
.var = "rsp",
ref_path = c("grp", "B"),
.spl_context = data.frame(
cur_col_split = I(list("grp")),
cur_col_split_val = I(list(c(grp = "A"))),
full_parent_df = I(list(dta))
),
.df_row = dta
)
l <- basic_table() |>
split_cols_by(var = "grp") |>
analyze(
"rsp",
afun = a_odds_ratio_j,
show_labels = "hidden",
extra_args = list(
ref_path = c("grp", "B"),
.stats = c("or_ci", "pval")
)
)
build_table(l, df = dta)
l2 <- basic_table() |>
split_cols_by(var = "grp") |>
analyze(
"rsp",
afun = a_odds_ratio_j,
show_labels = "hidden",
extra_args = list(
variables = list(arm = "grp", strata = "strata"),
method = "cmh",
ref_path = c("grp", "A"),
.stats = c("or_ci", "pval")
)
)
build_table(l2, df = dta)
s_odds_ratio_j(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta
)
s_odds_ratio_j(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata")
)
s_odds_ratio_j(
df = subset(dta, grp == "A"),
method = "cmh",
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = c("strata"))
)