View source: R/compute_or_mod.R
compute_or_mod | R Documentation |
Compute and format Odds-Ratio
from a model summary.
compute_or_mod(.coef_table, estimate, std_er, p_val = NULL, alpha = 0.05)
.coef_table |
A coefficient table, see details. |
estimate |
Quasiquoted name of estimate parameter. |
std_er |
Quasiquoted name of standard error parameter. |
p_val |
Quasiquoted name of p-value parameter. Optional. |
alpha |
alpha risk. |
Helper to compute and format Odds-Ratio based on
summary(glm)$coefficients
, or any equivalent in other modelling packages.
(see examples).
Preferably, it is transformed into a data.table or data.frame before being
evaluated in the function. Otherwise, compute_or_mod()
will transform it.
Significant OR-or column means low_ci is > 1.
The p_val
argument is only required if you wished to display a nice_p()
.
Output is a data.table. Actually, the function computes an Odds-Ratio, which is not necessarily a reporting Odds-Ratio.
A data.table with OR, confidence intervals (at 1 - alpha
),
significance (low_ci > 1
) and (optionally) p-value.
compute_dispro()
, add_drug()
, add_adr()
# Reporting Odds-Ratio of colitis with nivolumab among ICI cases.
demo <-
demo_ |>
add_drug(
d_code = ex_$d_drecno,
drug_data = drug_
) |>
add_adr(
a_code = ex_$a_llt,
adr_data = adr_
)
# Compute the model
mod <- glm(a_colitis ~ nivolumab, data = demo, family = "binomial")
# Extract coefficients
mod_summary <-
mod |>
summary()
coef_table <-
mod_summary$coefficients
# Transform coefficients into ORs with their CI
coef_table |>
compute_or_mod(
estimate = Estimate,
std_er = Std..Error,
p_val = Pr...z..)
# Also works if you don't have a p_val column
coef_table |>
compute_or_mod(
estimate = Estimate,
std_er = Std..Error)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.