forked from konfound-project/konfound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
117 lines (81 loc) · 4.86 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/konfound)](https://cran.r-project.org/package=konfound)
[![R build status](https://github.com/jrosen48/konfound/workflows/R-CMD-check/badge.svg)](https://github.com/jrosen48/konfound/actions)
[![Codecov test coverage](https://codecov.io/gh/jrosen48/konfound/branch/master/graph/badge.svg)](https://codecov.io/gh/jrosen48/konfound?branch=master)
<!-- badges: end -->
# konfound
In social science (and educational) research, we often wish to understand how robust inferences about effects are to unobserved (or controlled for) covariates, possible problems with measurement, and other sources of bias. 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:
```{r, eval = F}
install.packages("konfound")
```
You can install the development version from GitHub with:
```{r gh-installation, eval = FALSE}
install.packages("devtools")
devtools::install_github("jrosen48/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; (2) the impact of an omitted variable necessary to invalidate/sustain an inference for a regression coefficient:
```{r, eval = T}
library(konfound)
```
```{r}
pkonfound(est_eff = 2,
std_err = .4,
n_obs = 100,
n_covariates = 3)
```
## konfound() for models fit in R
`konfound()` calculates the same for models fit in R. For example, here are the coefficients for a linear model fit with `lm()` using the built-in dataset `mtcars`:
```{r}
m1 <- lm(mpg ~ wt + hp, 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:
```{r}
konfound(m1, wt)
```
## mkonfound for meta-analyses including sensitivity analysis
We can use an existing (and built-in) dataset, such as `mkonfound_ex`.
```{r}
mkonfound_ex
mkonfound(mkonfound_ex, t, df)
```
# Overview of available functionality
The above functions have a number of extensions; the below tables represent how `pkonfound()` and `konfound()` can be used:
```{r, echo = FALSE, message = FALSE}
library(dplyr)
structure(list("Outcome" = c("Continuous", "Logistic"
), `Predictor: Continuous` = c("`pkonfound(est_eff, std_err, n_obs, n_covariates)`",
"`pkonfound(est_eff, std_err, n_obs, n_covariates, model_type = 'logistic')`"), `Predictor: Binary` = c("`pkonfound(est_eff, std_err, n_obs, n_covariates)`", "`pkonfound(est_eff, std_err, n_obs, n_covariates, n_treat, model_type = 'logistic')` or `pkonfound(a, b, c, d)`")), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
)) %>%
knitr::kable()
structure(list("Outcome" = c("Continuous", "Logistic"), `Predictor: Continuous` = c("`konfound(m, var)`", "`konfound(m, var)`"), `Predictor: Binary` = c("`konfound(m, var)`", "`konfound(m, var, two_by_two = TRUE)`")), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
)) %>%
knitr::kable()
```
Note that there are additional arguments for each of thes functions; see `?pkonfound()` or `?konfound()` for more details.
# Other information
### How to learn more about sensitivity analysis
To learn more about sensitivity analysis, please visit:
* The [Introduction to konfound vignette](https://jrosen48.github.io/konfound/articles/Introduction_to_konfound.html), with detailed information about each of the functions (`pkonfound()`, `konfound()`, and `mkounfound()`)
* The causal inference section of Ken Frank's website [here](https://msu.edu/~kenfrank/research.htm#causal)
* The [konfound interactive web application](https://jmichaelrosenberg.shinyapps.io/shinykonfound/), with links to PowerPoints and key publications
### Feedback, issues, and feature requests
We prefer for issues to be filed via GitHub (link to the issues page for `konfound` [here](https://github.com/jrosen48/konfound/issues)) though we also welcome questions or feedback via email (see the DESCRIPTION file).
### Code of Conduct
Please note that this project is released with a Contributor Code of Conduct available at [https://www.contributor-covenant.org/version/1/0/0/](https://www.contributor-covenant.org/version/1/0/0/)