sjstats (version 0.17.5)

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, proportion of the incidence in the outcome variable (base line risk).

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

References

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

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

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 = 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
or_to_rr(1.913887, .5516)

# }

Run the code above in your browser using DataLab