odds_ratio | R Documentation |
Compares bivariate responses between two groups in terms of odds ratios along with a confidence interval.
estimate_odds_ratio(
lyt,
vars,
variables = list(arm = NULL, strata = NULL),
conf_level = 0.95,
groups_list = NULL,
na_str = default_na_str(),
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
.stats = "or_ci",
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_odds_ratio(
df,
.var,
.ref_group,
.in_ref_col,
.df_row,
variables = list(arm = NULL, strata = NULL),
conf_level = 0.95,
groups_list = NULL
)
a_odds_ratio(
df,
.var,
.ref_group,
.in_ref_col,
.df_row,
variables = list(arm = NULL, strata = NULL),
conf_level = 0.95,
groups_list = NULL
)
lyt |
( |
vars |
( |
variables |
(named |
conf_level |
( |
groups_list |
(named |
na_str |
( |
nested |
( |
... |
arguments passed to |
show_labels |
( |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
.ref_group |
( |
.in_ref_col |
( |
.df_row |
( |
This function uses either logistic regression for unstratified analyses, or conditional logistic regression for stratified analyses. The Wald confidence interval with the specified confidence level is calculated.
estimate_odds_ratio()
returns a layout object suitable for passing to further layouting functions,
or to rtables::build_table()
. Adding this function to an rtable
layout will add formatted rows containing
the statistics from s_odds_ratio()
to the table layout.
s_odds_ratio()
returns a named list with the statistics or_ci
(containing est
, lcl
, and ucl
) and n_tot
.
a_odds_ratio()
returns the corresponding list with formatted rtables::CellValue()
.
estimate_odds_ratio()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_odds_ratio()
: Statistics function which estimates the odds ratio
between a treatment and a control. A variables
list with arm
and strata
variable names must be passed if a stratified analysis is required.
a_odds_ratio()
: Formatted analysis function which is used as afun
in estimate_odds_ratio()
.
For stratified analyses, there is currently no implementation for conditional
likelihood confidence intervals, therefore the likelihood confidence interval is not
yet available as an option. Besides, when rsp
contains only responders or non-responders,
then the result values will be NA
, because no odds ratio estimation is possible.
Relevant helper function h_odds_ratio()
.
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))
)
l <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
estimate_odds_ratio(vars = "rsp")
build_table(l, df = dta)
# Unstratified analysis.
s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta
)
# Stratified analysis.
s_odds_ratio(
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")
)
a_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.