Skip to content

Commit

Permalink
Simulations for Simple Model (#4)
Browse files Browse the repository at this point in the history
This PR implements simulations for the simple model with a binary instrument and binary treatment.
  • Loading branch information
buddejul authored Sep 30, 2024
1 parent f9d5ad5 commit 69ce19e
Showing 67 changed files with 3,836 additions and 2,804 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.11']
# Currently only developing on windows.
os: [windows-latest]
# os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.12']
steps:
- uses: actions/checkout@v3
- name: create build environment
@@ -35,7 +37,7 @@ jobs:
micromamba activate gha-testing
pytest --cov-report=xml --cov=./
- name: Upload coverage report.
if: runner.os == 'Linux' && matrix.python-version == '3.11'
if: runner.os == 'Linux' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -24,3 +24,10 @@ bld/
*.pdf
*.run.xml
*.synctex.gz
*.synctex.gz.sum.synctex
*.toc
*.snm
*.nav

# Jupyter notebooks
*.ipynb
14 changes: 8 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -5,10 +5,12 @@ repos:
- id: check-useless-excludes
# - id: check-hooks-apply # Leave nbqa in here.
# - id: identity # Prints all files passed to pre-commits. Debugging.
- repo: https://github.com/lyz-code/yamlfix
rev: 1.13.0
hooks:
- id: yamlfix
# For some reason the yamlfix hook returns a ModuleNotFoundError:
# No module named 'maison.schema'. Deactivate it for now.
# - repo: https://github.com/lyz-code/yamlfix
# rev: 1.13.0
# hooks:
# - id: yamlfix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
@@ -36,7 +38,7 @@ repos:
rev: 23.9.1
hooks:
- id: black
language_version: python3.11
language_version: python3.12
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
@@ -91,7 +93,7 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
args: [--skip="**.ipynb"]
args: [-I, inst/WORDLIST.txt]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
46 changes: 33 additions & 13 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
---
name: thesis
channels: [conda-forge, nodefaults]
channels: [conda-forge, r, nodefaults]
dependencies:
- python ==3.12
- pip >=21.1

# Development dependencies
- conda-lock
- ipykernel
- jupyterlab
- pandas
- pip >=21.1
- plotly>=5.13.0
- pre-commit
- pytask-latex>=0.4.0
- pytask-parallel>=0.4.0
- pytask>=0.4.0

# Language agnostic template project dependencies
- pytask >=0.5.0
- pytask-latex >=0.4.2
- pytask-parallel >=0.5.0
- pytest
- pytest-cov
- pytest-xdist
- python-graphviz
- python=3.11
- pyyaml
- setuptools_scm

# Python template project dependencies
- statsmodels
- toml
- pip: [-e ., kaleido, pdbp]
- numpy
- pandas >=2.2
- plotly >=5.2.0,<6

# R template project dependencies
# Currently we are not using R hence we do not need to install these dependencies.
# - pytask-r >=0.4.1
# - pyreadr
# - r-plyr
# - r-precommit
# - r-yaml
# - r-forcats

# Install project
- pip:
- -e .
- pdbp
- kaleido==0.1.0.post1
- joblib
- git+https://github.com/buddejul/pyvmte@bernstein
- coptpy
6 changes: 6 additions & 0 deletions inst/WORDLIST → inst/WORDLIST.txt
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@ cirmmt
cls
conda
config
complier
compliers
cookiecutter
cov
CSE
@@ -97,6 +99,10 @@ Koepke
Kopka
KopkaDaly
Langtangen
late
lates
LATE
LATEs
LeClere
linux
Loong
26 changes: 26 additions & 0 deletions paper/figures/sm_sol_lower.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
\begin{tikzpicture}
\begin{axis}[
xmin=-1.1, xmax=1.1,
ymin=-1.1, ymax=1.1,
xlabel=$\beta_s$,
ylabel={$\underline{\beta^*}$},
xtick={-1, 0, 1}, % Specify the x-axis ticks here
ytick={-1, 1},
extra y ticks={-0.7, 0.3}, % Specify the positions of the special x-axis ticks together
extra y tick style={yticklabel style={color=black}}, % Apply a style to all extra x ticks
extra y tick labels={$-(1-\omega)$, $\omega$}, % Customize the labels of the special x-axis ticks
]

% Unconstrained solution
\addplot [domain=-1:1, color=black] {0.3*x - (1-0.3)};

% Solution with monotonicity constraint
\addplot [domain=-1:0, color=blue] {0.3*x - (1-0.3)};
\addplot [domain=0:1, color=blue] {x - (1-0.3)};

% Add text for each line
\node at (axis cs:-0.25, 0.75) [color=black, anchor=west] {\footnotesize No Constraint};
\node at (axis cs:-0.25, 0.5) [color=blue, anchor=west] {\footnotesize Increasing MTR Functions};

\end{axis}
\end{tikzpicture}
26 changes: 26 additions & 0 deletions paper/figures/sm_sol_upper.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
\begin{tikzpicture}
\begin{axis}[
xmin=-1.1, xmax=1.1,
ymin=-1.1, ymax=1.1,
xlabel=$\beta_s$,
ylabel={$\overline{\beta^*}$},
xtick={-1, 0, 1}, % Specify the x-axis ticks here
ytick={-1, 1},
extra y ticks={-0.3, 0.7}, % Specify the positions of the special x-axis ticks together
extra y tick style={yticklabel style={color=black}}, % Apply a style to all extra x ticks
extra y tick labels={$-\omega$, $1-\omega$}, % Customize the labels of the special x-axis ticks
]

% Unconstrained solution
\addplot [domain=-1:1, color=black] {1-0.3 + 0.3*x};

% Solution with monotonicity constraint
\addplot [domain=-1:0, color=blue] {x + 0.7};
\addplot [domain=0:1, color=blue] {0.3*x + 0.7};

% Add text for each line
\node at (axis cs:-0.25, -0.5) [color=black, anchor=west] {\footnotesize No Constraint};
\node at (axis cs:-0.25, -0.75) [color=blue, anchor=west] {\footnotesize Increasing MTR Functions};

\end{axis}
\end{tikzpicture}
28 changes: 28 additions & 0 deletions paper/figures/sm_upper_incr.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
\begin{tikzpicture}
\begin{axis}[
xmin=-0.1, xmax=1.1,
ymin=-0.1, ymax=1.1,
xlabel=$u$,
ylabel={$\E[Y(d)|U=u]$},
xtick={0,1}, % Specify the x-axis ticks here
extra x ticks={0.2, 0.5, 0.8}, % Specify the positions of the special x-axis ticks together
extra x tick style={xticklabel style={color=black}}, % Apply a style to all extra x ticks
extra x tick labels={$p(0)$, $p(1)$, $p(1) + \overline{u}$}, % Customize the labels of the special x-axis ticks
]

\addplot [domain=0.2:0.5, color=black] {0.2} node[pos=1, right] {\footnotesize $\theta_{20} = -\beta_s$};
\addplot [domain=0.2:0.5, color=black] {0} node[pos=1, right] {\footnotesize $\theta_{21} = 0$};

\draw [decorate,decoration={brace,amplitude=10pt,raise=0pt},yshift=0pt, xshift=-1pt]
(axis cs:0.2,0) -- (axis cs:0.2,0.2) node [black,midway,xshift=-1cm] {\footnotesize$-\beta_s$};

\addplot [domain=0.5:0.8, color=red] {0.2} node[pos=1, right, color=red] {\footnotesize $\theta_{30} = -\beta_s$};
\addplot [domain=0.5:0.8, color=red, dashed] {0} node[pos=1, right, color=red] {\footnotesize Infeasible};
\addplot [domain=0.5:0.8, color=red] {1} node[pos=1, right, color=red] {\footnotesize $\theta_{31} = 1$};

\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=0pt},yshift=0pt, xshift=1pt, color=red]
(axis cs:0.8,0.2) -- (axis cs:0.8,1) node [red,midway,xshift=1cm] {\footnotesize$\beta_u$};


\end{axis}
\end{tikzpicture}
27 changes: 27 additions & 0 deletions paper/figures/sm_upper_no_restr.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
\begin{tikzpicture}
\begin{axis}[
xmin=-0.1, xmax=1.1,
ymin=-0.1, ymax=1.1,
xlabel=$u$,
ylabel={$\E[Y(d)|U=u]$},
xtick={0,1}, % Specify the x-axis ticks here
extra x ticks={0.2, 0.5, 0.8}, % Specify the positions of the special x-axis ticks together
extra x tick style={xticklabel style={color=black}}, % Apply a style to all extra x ticks
extra x tick labels={$p(0)$, $p(1)$, $p(1) + \overline{u}$}, % Customize the labels of the special x-axis ticks
]

\addplot [domain=0.2:0.5, color=black] {0} node[pos=1, right] {\footnotesize $\theta_{20} = 0$};
\addplot [domain=0.2:0.5, color=black] {0.2} node[pos=1, right] {\footnotesize $\theta_{21} = 0.2$};

\draw [decorate,decoration={brace,amplitude=10pt,raise=0pt},yshift=0pt, xshift=-1pt]
(axis cs:0.2,0) -- (axis cs:0.2,0.2) node [black,midway,xshift=-1cm] {\footnotesize$\beta_s$};

\addplot [domain=0.5:0.8, color=red] {0} node[pos=1, right, color=red] {\footnotesize $\theta_{30} = 0$};
\addplot [domain=0.5:0.8, color=red] {1} node[pos=1, right, color=red] {\footnotesize $\theta_{31} = 1$};

\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=0pt},yshift=0pt, xshift=1pt, color=red]
(axis cs:0.8,0) -- (axis cs:0.8,1) node [red,midway,xshift=1cm] {\footnotesize$\beta_u$};


\end{axis}
\end{tikzpicture}
38 changes: 38 additions & 0 deletions paper/mte_papers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# MTE Papers

A collection of papers related to the MTE framework.
In particular, applied papers that employ the framework of Mogstad et al. ECMA.

## Applied Papers using Mogstad et al. ECMA Framework

### Rose and Shem-Tov 2021 JPE

Title: *How Does Incarceration Affect Reoffending? Estimating the Dose-Response Function*

They use and extend the MTE model for extrapolation. They don't provide inference.
For example, see Figure 5 and Table 6.

### Koichiro, Takanori Makoto AER

Title: Selection on Welfare Gains: Experimental Evidence from Electricity Plan Choice†

They don't seem to primarily use the MST method, but rather the parametric method of Brinch et al.


### Shea WP

https://jkcshea.github.io/

# To Check

- https://direct.mit.edu/rest/article-abstract/doi/10.1162/rest_a_01483/124131/The-Value-of-Piped-Water-and-Sewers-Evidence-from?redirectedFrom=fulltext
- https://direct.mit.edu/rest/article-abstract/105/3/646/102834/Reconciling-Seemingly-Contradictory-Results-from
- https://academic.oup.com/ej/article-abstract/132/646/2231/6548192
- https://academic.oup.com/restud/article-abstract/90/1/432/6582594
- https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4405043
- https://www.aeaweb.org/articles?id=10.1257/aer.20181756
- Appendix of https://academic.oup.com/qje/article-abstract/133/4/1885/5025665

# Misc

- Mismeasurement tratment: https://www.sciencedirect.com/science/article/pii/S0304407623002725
Loading

0 comments on commit 69ce19e

Please sign in to comment.