measures: Measures of effect

Description Usage Arguments Details Value References


The twoxtwo framework allows for estimation of the magnitude of association between an exposure and outcome. Measures of effect that can be calculated include odds ratio, risk ratio, and risk difference. Each measure can be calculated as a point estimate as well as the standard error (SE) around that value. It is critical to note that the interpretation of measures of effect depends on the study design and research question being investigated.

The odds_ratio(), risk_ratio(), and risk_diff() functions provide a standard interface for calculating measures of effect. Each function takes an input dataset and arguments for outcome and exposure as bare, unquoted variable names. If the input has the twoxtwo class then the effect measures will be calculated using exposure and outcome information from that object. The functions all return a tidy tibble with the name of the measure, the point estimate, and lower/upper bounds of a confidence interval (CI) based on the SE.

Formulas used in point estimate and SE calculations are available in 'Details'.


odds_ratio(.data, exposure, outcome, alpha = 0.05, ...)

risk_ratio(.data, exposure, outcome, alpha = 0.05, ...)

risk_diff(.data, exposure, outcome, alpha = 0.05, ...)



Either a data frame with observation-level exposure and outcome data or a twoxtwo object


Name of exposure variable; ignored if input to .data is a twoxtwo object


Name of outcome variable; ignored if input to .data is a twoxtwo object


Significance level to be used for constructing confidence interval; default is 0.05


Additional arguments passed to twoxtwo function; ignored if input to .data is a twoxtwo object


The formulas below denote cell values as A,B,C,D. For more on twoxtwo notation see the twoxtwo documentation.

Odds Ratio

OR = (A*D)/(B*C)

seOR = sqrt(1/A + 1/B + 1/C + 1/D)

Risk Ratio

RR = (A/(A+B)) / (C/(C+D))

seRR = sqrt(((1 - (A/(A+B)))/((A+B)*(A/(A+B)))) + ((1-(C/(C+D)))/((C+D)*(C/(C+D)))))

Risk Difference

RD = (A/(A+B)) - (C/(C+D))

seRD = sqrt(((A*B)/((A+B)^3)) + ((C*D)/((C+D)^3)))


A tibble with the following columns:


Tripepi, G., Jager, K. J., Dekker, F. W., Wanner, C., & Zoccali, C. (2007). Measures of effect: relative risks, odds ratios, risk difference, and 'number needed to treat'. Kidney international, 72(7), 789–791.

Walter S. D. (2000). Choice of effect measure for epidemiological data. Journal of clinical epidemiology, 53(9), 931–939.

Szklo, M., & Nieto, F. J. (2007). Epidemiology: Beyond the basics. Sudbury, Massachussets: Jones and Bartlett.

Keyes, K.M, & Galea S. (2014). Epidemiology Matters: A new introduction to methodological foundations. New York, New York: Oxford University Press.

twoxtwo documentation built on July 9, 2021, 9:08 a.m.