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.
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'.
1 2 3 4 5
Either a data frame with observation-level exposure and outcome data or a twoxtwo object
Name of exposure variable; ignored if input to
Name of outcome variable; ignored if input to
Significance level to be used for constructing confidence interval; default is
Additional arguments passed to twoxtwo function; ignored if input to
The formulas below denote cell values as A,B,C,D. For more on
twoxtwo notation see the twoxtwo documentation.
OR = (A*D)/(B*C)
seOR = sqrt(1/A + 1/B + 1/C + 1/D)
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)))))
RD = (A/(A+B)) - (C/(C+D))
seRD = sqrt(((A*B)/((A+B)^3)) + ((C*D)/((C+D)^3)))
tibble with the following columns:
measure: Name of the measure calculated
estimate: Point estimate for the effect measure
ci_lower: The lower bound of the confidence interval for the estimate
ci_upper: The upper bound of the confidence interval for the estimate
exposure: Name of the exposure variable followed by +/- levels (e.g. smoking::yes/no)
outcome: Name of the outcome variable followed by +/- levels (e.g. heart_disease::yes/no)
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. https://doi.org/10.1038/sj.ki.5002432
Walter S. D. (2000). Choice of effect measure for epidemiological data. Journal of clinical epidemiology, 53(9), 931–939. https://doi.org/10.1016/s0895-4356(00)00210-9
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.