Repo: https://github.com/a-torgovitsky/mtw2020mc
This package contains the code for the Monte Carlo simulations in "The Causal Interpretation of Two-Stage Least Squares with Multiple Instrumental Variables" by Mogstad, Torgovitsky, and Walters.
- Gurobi and the Gurobi R package gurobi, which can be obtained from Gurobi Optimization. A Gurobi software license is available at no cost to academic researchers. A clear installation guide for Gurobi can be found here.
- A LaTeX distribution, such as TeX live. (This is only required to convert figures made in
ggplot2
to Tikz. The code inplots.R
can be easily adjusted to save the nativeggplot2
figures by simply ignoring the functionprinttikz
.)
First make sure that the gurobi
package is installed and install devtools
if it isn't already installed:
install.packages("devtools")
Obtain the source files (e.g. clone the repo), then install dependencies from CRAN:
devtools::install_deps(pkg = ".", dependencies = TRUE)
Figures 1 and 2 in the supplemental appendix can then be replicated as follows:
devtools::load_all()
# Uncomment the following two lines and adjust workers if you want to run in parallel
# library("future")
# plan(multicore, workers = 35)
figure1()
figure2()
This will produce some csv files with data, some tex files for the figures, and some pdf's with compiled figures.