https://github.com/carloscinelli/iv.sensemakr
https://github.com/carloscinelli/iv.sensemakr
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/carloscinelli/iv.sensemakr
- Owner: carloscinelli
- Created: 2023-12-12T16:24:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-08T09:48:21.000Z (4 months ago)
- Last Synced: 2026-02-08T15:26:14.491Z (4 months ago)
- Language: R
- Size: 9.92 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# iv.sensemakr: Sensitivity Analysis Tools for IV
[](https://CRAN.R-project.org/package=iv.sensemakr)
[](https://github.com/carloscinelli/iv.sensemakr/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/carloscinelli/iv.sensemakr)
`iv.sensemakr` implements a suite of sensitivity analysis tools for instrumental variable estimates, as discussed in Cinelli, C. and Hazlett, C. (2025) "An Omitted Variable Bias Framework for Sensitivity Analysis of Instrumental Variables", *Biometrika* ([doi:10.1093/biomet/asaf004](https://doi.org/10.1093/biomet/asaf004); [PDF](https://carloscinelli.com/files/Cinelli%20and%20Hazlett%20-%20OVB%20for%20IV.pdf)).
# News
- `iv.sensemakr` is now on [CRAN!](https://CRAN.R-project.org/package=iv.sensemakr)
- Package website [is now online.](https://carloscinelli.com/iv.sensemakr/)
- Paper published in [Biometrika.](https://doi.org/10.1093/biomet/asaf004) You can find a [free version here.](https://carloscinelli.com/files/Cinelli%20and%20Hazlett%20-%20OVB%20for%20IV.pdf).
- Watch the [video of the talk at PCIC.](https://www.youtube.com/watch?v=ykZqPB1FPNo)
- Watch the [video of the talk at JSM.](https://www.youtube.com/watch?v=0b5VYWh8fN4)
# Installation
To install `iv.sensemakr` from CRAN:
```{r, eval = FALSE}
install.packages("iv.sensemakr")
```
To install the development version from GitHub, make sure you have the package `devtools` installed:
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("carloscinelli/iv.sensemakr")
```
# Basic usage
```{r basic-usage, fig.align='center', collapse=T, dpi=400, fig.width=10}
# loads package
library(iv.sensemakr)
# loads dataset
data("card")
# prepares data
y <- card$lwage # outcome
d <- card$educ # treatment
z <- card$nearc4 # instrument
x <- model.matrix( ~ exper + expersq + black + south + smsa + reg661 + reg662 +
reg663 + reg664 + reg665+ reg666 + reg667 + reg668 + smsa66,
data = card) # covariates
# fits IV model
card.fit <- iv_fit(y,d,z,x)
# see results
card.fit
# runs sensitivity analysis
card.sens <- sensemakr(card.fit, benchmark_covariates = c("black", "smsa"))
# see results
card.sens
# sensitivity contour plot
plot(card.sens, lim = 0.09)
# latex code for sensitivity table
ovb_minimal_reporting(card.sens, outcome_label = "lwage", treatment_label = "educ")
```
```{r results='asis'}
# html code for sensitivity table
ovb_minimal_reporting(card.sens, format = "pure_html",
outcome_label = "lwage", treatment_label = "educ")
```