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: github_document

Build Status CRAN_Status_Badge

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 use no use
cases 136 107
controls 297 165

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),
          bias_parms = c(.94, .85, .64, .25))
#> --Observed data-- 
#>          Outcome: UM+ 
#>        Comparing: Mobile+ vs. Mobile- 
#>     Mobile+ Mobile-
#> UM+     136     107
#> UM-     297     165
#>                                        2.5%     97.5%
#> Observed Relative Risk: 0.7984287 0.6518303 0.9779975
#>    Observed Odds Ratio: 0.7061267 0.5143958 0.9693215
#> ---
#> Selection Bias Corrected Relative Risk: 1.483780
#>    Selection Bias Corrected Odds Ratio: 1.634608

The 2X2 table is provided as a matrix and selection probabilities given with the argument bias_parms, 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 observed odds ratio (and relative risk) followed by the corrected ones.


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

  • Update description of parms in confounders, confounders.emm, and confounders.poly
  • New function confounders.array, sensitivity analysis for unmeasured confounders based on confounding imbalance among exposed and unexposed (Schneeweiss, 2006)
  • Deprecated bias parameters removed from function multidimBias. Please use bias_parms instead.
  • New function confounders.evalue, computing E-value to assess bias due to unmeasured confounder (VanderWeele and Ding, 2017)
  • New function multiple.bias allowing to extract 2-by-2 table from an episensr object to feed another function (multiple bias analysis)

episensr 0.9.2

  • Fix bug for distributions and computations of OR/RR in probsens.conf
  • Update distributions in probsens.irr.conf
  • Add example using probsens.conf in vignette

episensr 0.9.1

  • Fix bug when using triangular distribution in probsens.conf function for prevalence of exposure among the non-exposed (as producing NaNs) (#1).

episensr 0.9.0

  • Add misclassification_cov for a misclassified covariate (confounder or effect modifier).
  • As such, this (wrongly) added option into misclassification in the previous version is now removed.
  • Add computation of confidence interval for odds ratio as per Chu et al. for exposure misclassification.
  • Use bias_parms instead of bias in misclassification function.

episensr 0.8.0

  • Fix bug when building 2-by-2 table.

  • Various formatting improvements in output of confounders, confounders.emm, misclassification and selection functions.

  • Standardize use of bias_parms.

  • Add vignette.

  • Selection bias factor now available in output of selection function.

  • Add bootstrap option

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.


1.1.0 by Denis Haine, 2 months ago

Report a bug at

Browse source code at

Authors: Denis Haine [aut, cre]

Documentation:   PDF Manual  

GPL-2 license

Imports triangle, trapezoid, actuar, dagitty, ggdag, boot, magrittr

Depends on ggplot2

Suggests testthat, knitr, rmarkdown, aplore3, directlabels, tidyverse, lattice, covr

Depended on by apisensr.

See at CRAN