sjstats (version 0.17.9)

odds_to_rr: Get relative risks estimates from logistic regressions or odds ratio values

Description

odds_to_rr() converts odds ratios from a logistic regression model (including mixed models) into relative risks; or_to_rr() converts a single odds ratio estimate into a relative risk estimate.

Usage

odds_to_rr(fit)

or_to_rr(or, p0)

Arguments

fit

A fitted binomial generalized linear (mixed) model with logit-link function (logistic (multilevel) regression model).

or

Numeric, an odds ratio estimate.

p0

Numeric, the risk of having a positive outcome in the control or unexposed group (reference group), i.e. the number of outcome or "successes" in the control divided by the total number of observations in the control group.

Value

A data frame with relative risks and lower/upper confidence interval for the relative risks estimates; for or_to_rr(), the risk ratio estimate.

Details

This function extracts the odds ratios (exponentiated model coefficients) from logistic regressions (fitted with glm or glmer) and their related confidence intervals, and transforms these values into relative risks (and their related confidence intervals).

The formula for transformation is based on Zhang and Yu (1998), Wang (2013) and Grant (2014): RR <- OR / (1 - P0 + (P0 * OR)), where OR is the odds ratio and P0 indicates the proportion of the incidence in the outcome variable for the control group (reference group).

References

Grant RL. 2014. Converting an odds ratio to a range of plausible relative risks for better communication of research findings. BMJ 348:f7450. 10.1136/bmj.f7450

Wang Z. 2013. Converting Odds Ratio to Relative Risk in Cohort Studies with Partial Data Information. J Stat Soft 2013;55. 10.18637/jss.v055.i05

Zhang J, Yu KF. 1998. What's the Relative Risk? A Method of Correcting the Odds Ratio in Cohort Studies of Common Outcomes. JAMA; 280(19): 1690-1. 10.1001/jama.280.19.1690

Examples

Run this code
# NOT RUN {
library(sjmisc)
library(lme4)
# create binary response
sleepstudy$Reaction.dicho <- dicho(sleepstudy$Reaction, dich.by = "median")
# fit model
fit <- glmer(Reaction.dicho ~ Days + (Days | Subject),
             data = sleepstudy, family = binomial("logit"))
# convert to relative risks
odds_to_rr(fit)


data(efc)
# create binary response
y <- ifelse(efc$neg_c_7 < median(na.omit(efc$neg_c_7)), 0, 1)
# create data frame for fitted model
mydf <- data.frame(
  y = as.factor(y),
  sex = to_factor(efc$c161sex),
  dep = to_factor(efc$e42dep),
  barthel = efc$barthtot,
  education = to_factor(efc$c172code)
)
# fit model
fit <- glm(y ~., data = mydf, family = binomial(link = "logit"))
# convert to relative risks
odds_to_rr(fit)

# replicate OR/RR for coefficient "sex" from above regression
# p0 ~ .44, or ~ 1.914
prop.table(table(mydf$y, mydf$sex))
or_to_rr(1.914, 0.1055 / (.1324 + .1055))

# }

Run the code above in your browser using DataLab