compute_or_mod: Compute (r)OR from a model summary

View source: R/compute_or_mod.R

compute_or_modR Documentation

Compute (r)OR from a model summary

Description

[Stable] Compute and format Odds-Ratio from a model summary.

Usage

compute_or_mod(.coef_table, estimate, std_er, p_val = NULL, alpha = 0.05)

Arguments

.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.

Details

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.

Value

A data.table with OR, confidence intervals (at 1 - alpha), significance (low_ci > 1) and (optionally) p-value.

See Also

compute_dispro(), add_drug(), add_adr()

Examples


# 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)

vigicaen documentation built on April 3, 2025, 8:55 p.m.