pymte 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. pymte-1.0.0/.gitattributes +2 -0
  2. pymte-1.0.0/.github/workflows/ci.yml +62 -0
  3. pymte-1.0.0/.github/workflows/oracle.yml +30 -0
  4. pymte-1.0.0/.github/workflows/release.yml +37 -0
  5. pymte-1.0.0/.gitignore +13 -0
  6. pymte-1.0.0/.readthedocs.yaml +17 -0
  7. pymte-1.0.0/CITATION.cff +53 -0
  8. pymte-1.0.0/LICENSE +674 -0
  9. pymte-1.0.0/PKG-INFO +122 -0
  10. pymte-1.0.0/README.md +74 -0
  11. pymte-1.0.0/docs/_static/favicon.svg +4 -0
  12. pymte-1.0.0/docs/_templates/layout.html +4 -0
  13. pymte-1.0.0/docs/api.md +113 -0
  14. pymte-1.0.0/docs/citing.md +66 -0
  15. pymte-1.0.0/docs/conf.py +58 -0
  16. pymte-1.0.0/docs/datasets.md +40 -0
  17. pymte-1.0.0/docs/faq.md +37 -0
  18. pymte-1.0.0/docs/guide/audit.md +68 -0
  19. pymte-1.0.0/docs/guide/confidence-intervals.md +85 -0
  20. pymte-1.0.0/docs/guide/index.md +16 -0
  21. pymte-1.0.0/docs/guide/ivlike.md +80 -0
  22. pymte-1.0.0/docs/guide/mtr-specification.md +90 -0
  23. pymte-1.0.0/docs/guide/plotting.md +46 -0
  24. pymte-1.0.0/docs/guide/propensity.md +45 -0
  25. pymte-1.0.0/docs/guide/shape-restrictions.md +57 -0
  26. pymte-1.0.0/docs/guide/specification-tests.md +52 -0
  27. pymte-1.0.0/docs/guide/splines.md +50 -0
  28. pymte-1.0.0/docs/guide/target-parameters.md +111 -0
  29. pymte-1.0.0/docs/index.md +34 -0
  30. pymte-1.0.0/docs/installation.md +29 -0
  31. pymte-1.0.0/docs/migration.md +110 -0
  32. pymte-1.0.0/docs/quickstart.md +86 -0
  33. pymte-1.0.0/docs/theory.md +125 -0
  34. pymte-1.0.0/pyproject.toml +104 -0
  35. pymte-1.0.0/src/pymte/__init__.py +74 -0
  36. pymte-1.0.0/src/pymte/audit.py +547 -0
  37. pymte-1.0.0/src/pymte/callcheck.py +50 -0
  38. pymte-1.0.0/src/pymte/data/PROVENANCE.md +39 -0
  39. pymte-1.0.0/src/pymte/data/ae.csv.gz +0 -0
  40. pymte-1.0.0/src/pymte/data/ivmte_sim_data.csv.gz +0 -0
  41. pymte-1.0.0/src/pymte/datasets.py +55 -0
  42. pymte-1.0.0/src/pymte/design.py +100 -0
  43. pymte-1.0.0/src/pymte/ivlike.py +241 -0
  44. pymte-1.0.0/src/pymte/lp.py +625 -0
  45. pymte-1.0.0/src/pymte/monobound.py +311 -0
  46. pymte-1.0.0/src/pymte/mst.py +1649 -0
  47. pymte-1.0.0/src/pymte/mtr.py +390 -0
  48. pymte-1.0.0/src/pymte/plots.py +155 -0
  49. pymte-1.0.0/src/pymte/propensity.py +144 -0
  50. pymte-1.0.0/src/pymte/py.typed +0 -0
  51. pymte-1.0.0/src/pymte/splines.py +100 -0
  52. pymte-1.0.0/src/pymte/sweights.py +73 -0
  53. pymte-1.0.0/src/pymte/testdata.py +210 -0
  54. pymte-1.0.0/src/pymte/testfunctions_covariates.py +131 -0
  55. pymte-1.0.0/src/pymte/testfunctions_splines.py +122 -0
  56. pymte-1.0.0/src/pymte/wweights.py +178 -0
  57. pymte-1.0.0/tests/conftest.py +70 -0
  58. pymte-1.0.0/tests/fixtures/oracle/ae_ate_poly.json +235 -0
  59. pymte-1.0.0/tests/fixtures/oracle/ae_att_boolean_terms.json +203 -0
  60. pymte-1.0.0/tests/fixtures/oracle/ae_att_linear_u.json +195 -0
  61. pymte-1.0.0/tests/fixtures/oracle/ae_att_linear_u_boot50.json +281 -0
  62. pymte-1.0.0/tests/fixtures/oracle/ae_att_linear_u_linear_link.json +195 -0
  63. pymte-1.0.0/tests/fixtures/oracle/ae_att_linear_u_probit.json +195 -0
  64. pymte-1.0.0/tests/fixtures/oracle/ae_att_point_gmm.json +98 -0
  65. pymte-1.0.0/tests/fixtures/oracle/ae_att_point_gmm_boot50.json +188 -0
  66. pymte-1.0.0/tests/fixtures/oracle/ae_att_poly.json +235 -0
  67. pymte-1.0.0/tests/fixtures/oracle/ae_att_poly_uname_v.json +235 -0
  68. pymte-1.0.0/tests/fixtures/oracle/ae_att_regression_point.json +25 -0
  69. pymte-1.0.0/tests/fixtures/oracle/ae_att_splines.json +337 -0
  70. pymte-1.0.0/tests/fixtures/oracle/ae_att_splines_noint_shape.json +178 -0
  71. pymte-1.0.0/tests/fixtures/oracle/ae_att_splines_shape.json +337 -0
  72. pymte-1.0.0/tests/fixtures/oracle/ae_atu_poly.json +235 -0
  73. pymte-1.0.0/tests/fixtures/oracle/dist_basic_dist.csv +13 -0
  74. pymte-1.0.0/tests/fixtures/oracle/dist_basic_full.csv +1001 -0
  75. pymte-1.0.0/tests/fixtures/oracle/dist_covariates_dist.csv +37 -0
  76. pymte-1.0.0/tests/fixtures/oracle/dist_covariates_full.csv +10001 -0
  77. pymte-1.0.0/tests/fixtures/oracle/dist_mosquito.csv +401 -0
  78. pymte-1.0.0/tests/fixtures/oracle/dist_splines_dist.csv +7 -0
  79. pymte-1.0.0/tests/fixtures/oracle/dist_splines_full.csv +4201 -0
  80. pymte-1.0.0/tests/fixtures/oracle/halton.json +7 -0
  81. pymte-1.0.0/tests/fixtures/oracle/sim_custom_weights_late_x2.json +212 -0
  82. pymte-1.0.0/tests/fixtures/oracle/sim_equal_coef_regression_point.json +27 -0
  83. pymte-1.0.0/tests/fixtures/oracle/sim_genlate.json +212 -0
  84. pymte-1.0.0/tests/fixtures/oracle/sim_genlate_x2.json +212 -0
  85. pymte-1.0.0/tests/fixtures/oracle/sim_late.json +212 -0
  86. pymte-1.0.0/tests/fixtures/oracle/sim_late_boot50.json +298 -0
  87. pymte-1.0.0/tests/fixtures/oracle/sim_late_boot50_m2000_subsample.json +298 -0
  88. pymte-1.0.0/tests/fixtures/oracle/sim_late_x2.json +212 -0
  89. pymte-1.0.0/tests/fixtures/oracle/sim_late_x8.json +212 -0
  90. pymte-1.0.0/tests/fixtures/oracle/sim_lp_spec_test_boot50.json +234 -0
  91. pymte-1.0.0/tests/fixtures/oracle/sim_multi_ivlike.json +368 -0
  92. pymte-1.0.0/tests/fixtures/oracle/sim_multi_ivlike_components.json +263 -0
  93. pymte-1.0.0/tests/fixtures/oracle/sim_multi_ivlike_subset.json +374 -0
  94. pymte-1.0.0/tests/fixtures/oracle/sim_point_gmm.json +119 -0
  95. pymte-1.0.0/tests/fixtures/oracle/sim_point_gmm_eyeweight.json +119 -0
  96. pymte-1.0.0/tests/fixtures/oracle/sim_point_gmm_many_moments.json +161 -0
  97. pymte-1.0.0/tests/fixtures/oracle/sim_point_lp_tol0.json +147 -0
  98. pymte-1.0.0/tests/fixtures/oracle/sim_point_regression_equal_coef.json +24 -0
  99. pymte-1.0.0/tests/fixtures/oracle/sim_point_regression_ols.json +24 -0
  100. pymte-1.0.0/tests/fixtures/oracle/sim_shape_ignored_point.json +119 -0
  101. pymte-1.0.0/tests/fixtures/oracle/sim_spec_test_boot50.json +211 -0
  102. pymte-1.0.0/tests/fixtures/oracle/splines.json +2202 -0
  103. pymte-1.0.0/tests/fixtures/oracle/tt_covariates.json +247 -0
  104. pymte-1.0.0/tests/fixtures/oracle/tt_single.json +166 -0
  105. pymte-1.0.0/tests/fixtures/oracle/tt_splines.json +262 -0
  106. pymte-1.0.0/tests/fixtures/oracle/tt_splines_custom_weights.json +262 -0
  107. pymte-1.0.0/tests/fixtures/run_oracle.R +461 -0
  108. pymte-1.0.0/tests/test_arguments.py +128 -0
  109. pymte-1.0.0/tests/test_bootstrap.py +159 -0
  110. pymte-1.0.0/tests/test_covariates.py +185 -0
  111. pymte-1.0.0/tests/test_datasets.py +52 -0
  112. pymte-1.0.0/tests/test_direct_qp.py +111 -0
  113. pymte-1.0.0/tests/test_moments.py +218 -0
  114. pymte-1.0.0/tests/test_mtr.py +130 -0
  115. pymte-1.0.0/tests/test_parity.py +296 -0
  116. pymte-1.0.0/tests/test_plots.py +55 -0
  117. pymte-1.0.0/tests/test_propensity.py +61 -0
  118. pymte-1.0.0/tests/test_single.py +128 -0
  119. pymte-1.0.0/tests/test_splines.py +224 -0
  120. pymte-1.0.0/tests/test_uspline.py +41 -0
@@ -0,0 +1,2 @@
1
+ * text=auto eol=lf
2
+ *.csv.gz binary
@@ -0,0 +1,62 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install ".[dev]"
17
+ - run: ruff check .
18
+ - run: ruff format --check .
19
+ - run: mypy
20
+
21
+ package:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.12"
28
+ - run: pip install build twine
29
+ - run: python -m build
30
+ - run: twine check dist/*
31
+ - run: pip install dist/*.whl
32
+ - run: python -c "import pymte; print(pymte.__version__)"
33
+
34
+ test:
35
+ runs-on: ${{ matrix.os }}
36
+ strategy:
37
+ fail-fast: false
38
+ matrix:
39
+ os: [ubuntu-latest]
40
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
41
+ include:
42
+ - os: windows-latest
43
+ python-version: "3.12"
44
+ - os: macos-latest
45
+ python-version: "3.12"
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: actions/setup-python@v5
49
+ with:
50
+ python-version: ${{ matrix.python-version }}
51
+ - run: pip install ".[dev,plots]"
52
+ - run: pytest
53
+
54
+ docs:
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+ - uses: actions/setup-python@v5
59
+ with:
60
+ python-version: "3.12"
61
+ - run: pip install ".[docs]"
62
+ - run: sphinx-build -W --keep-going -b html docs docs/_build/html
@@ -0,0 +1,30 @@
1
+ name: R oracle
2
+
3
+ # Regenerates the R reference fixtures with the current R package and runs
4
+ # the parity tests against them. Informational: it never blocks a push.
5
+
6
+ on:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ oracle:
11
+ runs-on: ubuntu-latest
12
+ continue-on-error: true
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: r-lib/actions/setup-r@v2
16
+ with:
17
+ r-version: "release"
18
+ - uses: r-lib/actions/setup-r-dependencies@v2
19
+ with:
20
+ packages: |
21
+ any::ivmte
22
+ any::lpSolveAPI
23
+ any::splines2
24
+ any::jsonlite
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.12"
28
+ - run: pip install ".[dev]"
29
+ - run: Rscript tests/fixtures/run_oracle.R tests/fixtures/oracle
30
+ - run: pytest tests/test_parity.py tests/test_moments.py tests/test_propensity.py tests/test_uspline.py tests/test_datasets.py tests/test_bootstrap.py
@@ -0,0 +1,37 @@
1
+ name: Release
2
+
3
+ # Builds the package when a version tag is pushed and uploads it to PyPI
4
+ # through trusted publishing (no API token is stored in the repository).
5
+
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+ - run: pip install build twine
19
+ - run: python -m build
20
+ - run: twine check dist/*
21
+ - uses: actions/upload-artifact@v4
22
+ with:
23
+ name: dist
24
+ path: dist/
25
+
26
+ publish:
27
+ needs: build
28
+ runs-on: ubuntu-latest
29
+ environment: pypi
30
+ permissions:
31
+ id-token: write
32
+ steps:
33
+ - uses: actions/download-artifact@v4
34
+ with:
35
+ name: dist
36
+ path: dist/
37
+ - uses: pypa/gh-action-pypi-publish@release/v1
pymte-1.0.0/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ dist/
6
+ .venv/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ docs/_build/
11
+ docs/generated/
12
+ docs/jupyter_execute/
13
+ .ipynb_checkpoints/
@@ -0,0 +1,17 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.12"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+ fail_on_warning: true
11
+
12
+ python:
13
+ install:
14
+ - method: pip
15
+ path: .
16
+ extra_requirements:
17
+ - docs
@@ -0,0 +1,53 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this package, please cite the methodological papers listed under references as well as the software."
3
+ title: "pymte: instrumental variables and marginal treatment effects in Python"
4
+ type: software
5
+ authors:
6
+ - family-names: Ronczewski
7
+ given-names: Alex
8
+ license: GPL-3.0-or-later
9
+ repository-code: "https://github.com/alexr951/pymte"
10
+ abstract: >-
11
+ A Python port of the R package ivmte by Joshua Shea and Alexander
12
+ Torgovitsky, implementing the marginal treatment effect framework of
13
+ Mogstad, Santos and Torgovitsky (2018).
14
+ references:
15
+ - type: article
16
+ title: "Using Instrumental Variables for Inference About Policy Relevant Treatment Parameters"
17
+ authors:
18
+ - family-names: Mogstad
19
+ given-names: Magne
20
+ - family-names: Santos
21
+ given-names: Andres
22
+ - family-names: Torgovitsky
23
+ given-names: Alexander
24
+ journal: Econometrica
25
+ volume: 86
26
+ issue: 5
27
+ start: 1589
28
+ end: 1619
29
+ year: 2018
30
+ doi: 10.3982/ECTA15463
31
+ - type: article
32
+ title: "ivmte: An R Package for Extrapolating Instrumental Variable Estimates Away From Compliers"
33
+ authors:
34
+ - family-names: Shea
35
+ given-names: Joshua
36
+ - family-names: Torgovitsky
37
+ given-names: Alexander
38
+ journal: Observational Studies
39
+ volume: 9
40
+ issue: 2
41
+ start: 1
42
+ end: 42
43
+ year: 2023
44
+ doi: 10.1353/obs.2023.0016
45
+ - type: software
46
+ title: "ivmte: Instrumental Variables: Extrapolation by Marginal Treatment Effects"
47
+ authors:
48
+ - family-names: Shea
49
+ given-names: Joshua
50
+ - family-names: Torgovitsky
51
+ given-names: Alexander
52
+ repository-code: "https://github.com/jkcshea/ivmte"
53
+ license: GPL-3.0