h_odds_ratio {junco} | R Documentation |
Helper functions for odds ratio estimation
Description
Functions to calculate odds ratios in s_odds_ratio_j()
.
Usage
or_glm_j(data, conf_level)
or_clogit_j(data, conf_level, method = "exact")
or_cmh(data, conf_level)
Arguments
data |
( |
conf_level |
( |
method |
( |
Value
A named list
of elements or_ci
, n_tot
and pval
.
Functions
-
or_glm_j()
: Estimates the odds ratio based onstats::glm()
. Note that there must be exactly 2 groups indata
as specified by thegrp
variable. -
or_clogit_j()
: Estimates the odds ratio based onsurvival::clogit()
. This is done for the whole data set including all groups, since the results are not the same as when doing pairwise comparisons between the groups. -
or_cmh()
: Estimates the odds ratio based on CMH. Note that there must be exactly 2 groups indata
as specified by thegrp
variable.
See Also
Examples
data <- data.frame(
rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1)),
grp = letters[c(1, 1, 1, 2, 2, 2, 1, 2)],
strata = letters[c(1, 2, 1, 2, 2, 2, 1, 2)],
stringsAsFactors = TRUE
)
or_glm_j(data, conf_level = 0.95)
data <- data.frame(
rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)),
grp = letters[c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3)],
strata = LETTERS[c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)],
stringsAsFactors = TRUE
)
or_clogit_j(data, conf_level = 0.95)
set.seed(123)
data <- data.frame(
rsp = as.logical(rbinom(n = 40, size = 1, prob = 0.5)),
grp = letters[sample(1:2, size = 40, replace = TRUE)],
strata = LETTERS[sample(1:2, size = 40, replace = TRUE)],
stringsAsFactors = TRUE
)
or_cmh(data, conf_level = 0.95)