Basic Sensitivity Analysis of Epidemiological Results

Basic sensitivity analysis of the observed relative risks adjusting for unmeasured confounding and misclassification of the exposure/outcome, or both. It follows the bias analysis methods and examples from the book by Lash T.L, Fox M.P, and Fink A.K. "Applying Quantitative Bias Analysis to Epidemiologic Data", ('Springer', 2009).

output: md_document: variant: markdown_github

The R package episensr allows to do basic sensitivity analysis of epidemiological results as described in Applying Quantitative Bias Analysis to Epidemiological Data by Timothy L. Lash, Matthew P. Fox, and Aliza K. Fink (ISBN: 978-0-387-87960-4, bias.analysis). A similar function is available in Stata (episens).

This package is free and open source software, licensed under GPL2.

We will use a case-control study by Stang et al. on the relation between mobile phone use and uveal melanoma. The observed odds ratio for the association between regular mobile phone use vs. no mobile phone use with uveal melanoma incidence is 0.71 [95% CI 0.51-0.97]. But there was a substantial difference in participation rates between cases and controls (94% vs 55%, respectively) and so selection bias could have an impact on the association estimate. The 2X2 table for this study is the following:

regular useno use

We use the function selection as shown below.

selection(matrix(c(136, 107, 297, 165),
                 dimnames = list(c("UM+", "UM-"), c("Mobile+", "Mobile-")),
                 nrow = 2, byrow = TRUE),
          selprob = c(.94, .85, .64, .25))
#> Observed Data: 
#> --------------------------------------------------- 
#> Outcome   : UM+ 
#> Comparing : Mobile+ vs. Mobile- 
#>     Mobile+ Mobile-
#> UM+     136     107
#> UM-     297     165
#> Data Corrected for Selected Proportions: 
#> ---------------------------------------------------
#>      Mobile+  Mobile-
#> UM+ 144.6809 125.8824
#> UM- 464.0625 660.0000
#>                                95% conf. interval
#> Observed Relative Risk: 0.7984    0.6518   0.9780
#>    Observed Odds Ratio: 0.7061    0.5144   0.9693
#>                                           [,1]
#> Selection Bias Corrected Relative Risk: 1.4838
#>    Selection Bias Corrected Odds Ratio: 1.6346
#>                                                 [,1]
#>      Selection probability among cases exposed: 0.94
#>    Selection probability among cases unexposed: 0.85
#>   Selection probability among noncases exposed: 0.64
#> Selection probability among noncases unexposed: 0.25

The 2X2 table is provided as a matrix and selection probabilities given with the argument selprob, a vector with the 4 probabilities (guided by the participation rates in cases and controls) in the following order: among cases exposed, among cases unexposed, among noncases exposed, and among noncases unexposed. The output shows the observed 2X2 table, the same table corrected for the selection proportions, the observed odds ratio (and relative risk) followed by the corrected ones, and the input parameters.

Here's an other example to correct for selection bias caused by M bias.

mbias(or = c(2, 5.4, 2.5, 1.5, 1),
      var = c("HIV", "Circumcision", "Muslim", "Low CD4", "Participation"))
#> Correction for selection bias: 
#> ---------------------------------------- 
#> OR observed between the exposure and the outcome: 1 
#>              Maximum bias from conditioning on P: 1.006236 
#>                  OR corrected for selection bias: 0.9938024

You can get the latest release from CRAN:


Or install the development version from GitHub with devtools package:

devtools::install_github('dhaine/episensr', ref = "develop")


episensr 0.7.2

  • Fix 2-by-2 tables when variables are provided instead of a matrix.

episensr 0.7.1

  • Fix R version dependency (R >= 3.2.0)

episensr 0.7.0

  • Harmonization of arguments across functions.

  • New distributions added to probsens series of functions: constant, logit-logistic, logit-normal, log-logistic, and log-normal.

  • Probabilistic analysis of person-time data added with probsens.irr for exposure misclassification, and probsens.irr.conf for unmeasured confounder.

  • Sensitivity analysis to correct for selection bias caused by M bias with mbias function, including DAG plot and print function.

  • Fix CI formatting.

  • NAMESPACE: add imports to stats functions to avoid new R CMD CHECK warnings

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.9.2 by Denis Haine, a month ago

Report a bug at

Browse source code at

Authors: Denis Haine [aut, cre]

Documentation:   PDF Manual  

GPL-2 license

Imports triangle, trapezoid, actuar, llogistic, logitnorm, plyr, ggplot2, grid, gridExtra, reshape, boot

Suggests testthat, knitr, rmarkdown, aplore3

See at CRAN