knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>",
    fig.path = "README-"
)

CRAN status R-CMD-check codecov DOI

konfound

The goal of konfound is to carry out sensitivity analysis to help analysts to quantify how robust inferences are to potential sources of bias. This R package provides tools to carry out sensitivity analysis as described in Frank, Maroulis, Duong, and Kelcey (2013) based on Rubin’s (1974) causal model as well as in Frank (2000) based on the impact threshold for a confounding variable.

Installation

You can install the CRAN version of konfound with:

install.packages("konfound")

You can install the development version from GitHub with:

install.packages("devtools")
devtools::install_github("konfound-project/konfound")

Use of konfound

pkonfound() for published studies

pkonfound(), for published studies, calculates (1) how much bias there must be in an estimate to invalidate/sustain an inference, and interprets in terms of how much data would need to be replaced to nullify an inference (Robustness of an Inference to Replacement, RIR); (2) the impact of an omitted variable necessary to invalidate/sustain an inference for a regression coefficient (Impact Threshold of a Confounding Variable, ITCV). RIR is reported by default. ITCV can be generated by specifying index = "IT".

library(konfound)
pkonfound(est_eff = 2, 
          std_err = .4, 
          n_obs = 100, 
          n_covariates = 3)
pkonfound(est_eff = 2, 
          std_err = .4, 
          n_obs = 100, 
          n_covariates = 3, 
          index = "IT")

konfound() for models fit in R

konfound() calculates the robustness of inferences for models fit in R. For example, below are the coefficients for a linear model fit with lm() using the built-in dataset mtcars:

m1 <- lm(mpg ~ wt + disp, data = mtcars)
m1
summary(m1)

Sensitivity analysis for the effect for wt on mpg can be carried out as follows, specifying the fitted model object:

konfound(m1, wt)

Similar to pkonfound, ITCV can be generated by specifying index = "IT".

konfound(m1, wt, index = "IT")

mkonfound for meta-analyses including sensitivity analysis

mkonfound() supports sensitivity that can be compared or synthesized across multiple analyses. We can use an existing (and built-in) dataset, such as mkonfound_ex.

mkonfound_ex
mkonfound(mkonfound_ex, t, df)

Other information

How to learn more about sensitivity analysis

To learn more about sensitivity analysis, please visit:

Issues, feature requests, and contributing

We prefer for issues to be filed via GitHub (link to the issues page for konfound here) though we also welcome questions or feedback requests via email (see the DESCRIPTION file).

Contributing guidelines are here.

Code of Conduct

Please note that the konfound project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



jrosen48/konfound documentation built on Nov. 21, 2024, 4:42 a.m.