Skip to content

Commit ac36ffc

Browse files
authored
Merge pull request #215 from pymc-labs/references
Enable bibtex references in the documentation
2 parents 6817574 + e7a3448 commit ac36ffc

17 files changed

+176
-139
lines changed

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636
- repo: https://github.com/econchick/interrogate
3737
rev: 1.5.0
3838
hooks:
39-
- id: interrogate
40-
# needed to make excludes in pyproject.toml work
41-
# see here https://github.com/econchick/interrogate/issues/60#issuecomment-735436566
42-
pass_filenames: false
39+
- id: interrogate
40+
# needed to make excludes in pyproject.toml work
41+
# see here https://github.com/econchick/interrogate/issues/60#issuecomment-735436566
42+
pass_filenames: false

docs/source/_static/interrogate_badge.svg

+3-3
Loading

docs/source/conf.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,36 @@
4646
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
4747

4848
extensions = [
49-
"myst_parser",
50-
"nbsphinx",
49+
"myst_nb",
50+
"sphinxcontrib.bibtex",
5151
"sphinx.ext.autodoc",
5252
"sphinx.ext.intersphinx",
5353
"sphinx.ext.mathjax",
5454
"sphinx_autodoc_typehints",
5555
]
5656

57-
source_suffix = [".rst", ".md"]
57+
nb_execution_mode = "off"
58+
59+
source_suffix = {
60+
".rst": "restructuredtext",
61+
".ipynb": "myst-nb",
62+
".myst": "myst-nb",
63+
}
5864
templates_path = ["_templates"]
5965
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
6066
master_doc = "index"
6167

68+
# bibtex config
69+
bibtex_bibfiles = ["references.bib"]
70+
bibtex_default_style = "unsrt"
71+
bibtex_reference_style = "author_year"
72+
6273
# -- intersphinx config -------------------------------------------------------
6374
intersphinx_mapping = {
6475
"python": ("https://docs.python.org/3", None),
6576
"pymc": ("https://www.pymc.io/projects/docs/en/stable/", None),
6677
}
6778

68-
# -- nbsphinx config ----------------------------------------------------------
69-
# Opt out of executing the notebooks remotely. This will save time in the remote build
70-
# process on readthedocs. The notebooks in /docs/notebooks will be parsed/converted,
71-
# but not re-executed.
72-
nbsphinx_execute = "never"
73-
7479
# MyST options for working with markdown files.
7580
# Info about extensions here https://myst-parser.readthedocs.io/en/latest/syntax/optional.html?highlight=math#admonition-directives # noqa: E501
7681
myst_enable_extensions = [

docs/source/glossary.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Glossary
22

3-
<div class="admonition note" name="html-admonition">
4-
<p class="title">Note:</p>
5-
Some of the definitions have been copied from (or inspired by) various resources, including Reichardt (2019).
6-
</div>
7-
3+
:::{note}
4+
Some of the definitions have been copied from (or inspired by) various resources, including {cite:t}`reichardt2019quasi`.
5+
:::
86

97
**ANCOVA:** Analysis of covariance is a simple linear model, typically with one continuous predictor (the covariate) and a catgeorical variable (which may correspond to treatment or control group). In the context of this package, ANCOVA could be useful in pre-post treatment designs, either with or without random assignment. This is similar to the approach of difference in differences, but only applicable with a single pre and post treatment measure.
108

@@ -63,4 +61,6 @@ Data from pretest-posttest NEGD could be analysed using change score analysis or
6361
**Treatment effect:** The difference in outcomes between what happened after a treatment is implemented and what would have happened (see Counterfactual) if the treatment had not been implemented, assuming everything else had been the same.
6462

6563
## References
66-
* Reichardt, C. S. (2019). Quasi-experimentation: A guide to design and analysis. Guilford Publications.
64+
:::{bibliography}
65+
:filter: docname in docnames
66+
:::

docs/source/notebooks/ancova_pymc.ipynb

+5-12
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
"source": [
88
"# ANCOVA for pre/post treatment nonequivalent group designs\n",
99
"\n",
10-
"<div class=\"alert alert-warning\">\n",
11-
"\n",
12-
"Warning\n",
13-
"\n",
10+
":::{note}\n",
1411
"This is a preliminary example based on synthetic data. It will hopefully soon be updated with data from a real study.\n",
15-
"\n",
16-
"</div>\n",
12+
":::\n",
1713
"\n",
1814
"In cases where there is just one pre and one post treatment measurement, it we can analyse data from NEGD experiments using an ANCOVA type approach. The basic model is:\n",
1915
"\n",
@@ -56,6 +52,7 @@
5652
]
5753
},
5854
{
55+
"attachments": {},
5956
"cell_type": "markdown",
6057
"metadata": {},
6158
"source": [
@@ -219,13 +216,9 @@
219216
"source": [
220217
"## Run the analysis\n",
221218
"\n",
222-
"<div class=\"alert alert-info\">\n",
223-
"\n",
224-
"Note:\n",
225-
"\n",
219+
":::{note}\n",
226220
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
227-
"\n",
228-
"</div>"
221+
":::"
229222
]
230223
},
231224
{

docs/source/notebooks/did_pymc.ipynb

+5-12
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
"source": [
88
"# Difference in Differences with `pymc` models\n",
99
"\n",
10-
"<div class=\"alert alert-warning\">\n",
11-
"\n",
12-
"Warning\n",
13-
"\n",
10+
":::{note}\n",
1411
"This example is in-progress! Further elaboration and explanation will follow soon.\n",
15-
"\n",
16-
"</div>"
12+
":::"
1713
]
1814
},
1915
{
@@ -40,6 +36,7 @@
4036
]
4137
},
4238
{
39+
"attachments": {},
4340
"cell_type": "markdown",
4441
"metadata": {},
4542
"source": [
@@ -150,13 +147,9 @@
150147
"source": [
151148
"## Run the analysis\n",
152149
"\n",
153-
"<div class=\"alert alert-info\">\n",
154-
"\n",
155-
"Note:\n",
156-
"\n",
150+
":::{note}\n",
157151
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
158-
"\n",
159-
"</div>"
152+
":::"
160153
]
161154
},
162155
{

docs/source/notebooks/did_pymc_banks.ipynb

+15-19
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
"source": [
88
"# Banking dataset with a `pymc` model\n",
99
"\n",
10-
"<div class=\"alert alert-warning\">\n",
11-
"\n",
12-
"Warning\n",
13-
"\n",
10+
":::{note}\n",
1411
"This example is in-progress! Further elaboration and explanation will follow soon.\n",
12+
":::\n",
1513
"\n",
16-
"</div>\n",
17-
"\n",
18-
"This notebook analyses historic data on banking closures from [Richardson & Troost (2009)](http://masteringmetrics.com/wp-content/uploads/2015/02/Richardson_Troost_2009_JPE.pdf) and used as a case study for a difference in differences analysis in the [Mastering Metrics](http://www.masteringmetrics.com) book. Here, we replicate this analysis, but using Bayesian inference."
14+
"This notebook analyses historic data on banking closures from {cite:t}`richardson2009monetary` and used as a case study for a difference in differences analysis in the excellent book [Mastering Metrics](http://www.masteringmetrics.com) {cite:p}`angrist2014mastering`. Here, we replicate this analysis, but using Bayesian inference."
1915
]
2016
},
2117
{
@@ -49,7 +45,7 @@
4945
"source": [
5046
"## Load data\n",
5147
"\n",
52-
"The raw dataset has a `date` columns which is just some uninterpretable number. All we need for our analysis is the `year` column. We also have columns `bib6`, `bio6`, `bib8`, `bio8`. We know that the `6` and `8` represent the 6th and 8th Federal Reserve districts, respectively. I assume `bib` means \"banks in business\", so I'll discard the `bib*` columns. The data is at daily resolution, but we will convert this to yearly resolution. And from what I can tell from Figure 5.2 of the [Mastering Metrics](http://www.masteringmetrics.com) book, they seem to present the _median_ number of banks open per year. Let's load the data up and do those steps."
48+
"The raw dataset has a `date` columns which is just some uninterpretable number. All we need for our analysis is the `year` column. We also have columns `bib6`, `bio6`, `bib8`, `bio8`. We know that the `6` and `8` represent the 6th and 8th Federal Reserve districts, respectively. I assume `bib` means \"banks in business\", so I'll discard the `bib*` columns. The data is at daily resolution, but we will convert this to yearly resolution. And from what I can tell from Figure 5.2 of the {cite:t}`angrist2014mastering`, they seem to present the _median_ number of banks open per year. Let's load the data up and do those steps."
5349
]
5450
},
5551
{
@@ -170,7 +166,7 @@
170166
"cell_type": "markdown",
171167
"metadata": {},
172168
"source": [
173-
"Let's visualise what we have. This matches up exactly with Figure 5.2 of the [Mastering Metrics](http://www.masteringmetrics.com) book."
169+
"Let's visualise what we have. This matches up exactly with Figure 5.2 of the {cite:t}`angrist2014mastering`."
174170
]
175171
},
176172
{
@@ -395,13 +391,9 @@
395391
"cell_type": "markdown",
396392
"metadata": {},
397393
"source": [
398-
"<div class=\"alert alert-info\">\n",
399-
"\n",
400-
"Note:\n",
401-
"\n",
394+
":::{note}\n",
402395
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
403-
"\n",
404-
"</div>"
396+
":::"
405397
]
406398
},
407399
{
@@ -636,11 +628,15 @@
636628
]
637629
},
638630
{
639-
"cell_type": "code",
640-
"execution_count": null,
631+
"attachments": {},
632+
"cell_type": "markdown",
641633
"metadata": {},
642-
"outputs": [],
643-
"source": []
634+
"source": [
635+
"## References\n",
636+
":::{bibliography}\n",
637+
":filter: docname in docnames\n",
638+
":::"
639+
]
644640
}
645641
],
646642
"metadata": {

docs/source/notebooks/geolift1.ipynb

+2-6
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,9 @@
268268
"\n",
269269
"We can use `CausalPy`'s API to run this procedure, but using Bayesian inference methods as follows:\n",
270270
"\n",
271-
"<div class=\"alert alert-info\">\n",
272-
"\n",
273-
"Note:\n",
274-
"\n",
271+
":::{note}\n",
275272
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
276-
"\n",
277-
"</div>"
273+
":::"
278274
]
279275
},
280276
{

docs/source/notebooks/its_covid.ipynb

+2-6
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,9 @@
181181
"\n",
182182
"In this example we are going to standardize the data. So we have to be careful in how we interpret the inferred regression coefficients, and the posterior predictions will be in this standardized space.\n",
183183
"\n",
184-
"<div class=\"alert alert-info\">\n",
185-
"\n",
186-
"Note:\n",
187-
"\n",
184+
":::{note}\n",
188185
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
189-
"\n",
190-
"</div>"
186+
":::"
191187
]
192188
},
193189
{

docs/source/notebooks/its_pymc.ipynb

+6-18
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,9 @@
162162
"source": [
163163
"Run the analysis\n",
164164
"\n",
165-
"<div class=\"alert alert-info\">\n",
166-
"\n",
167-
"Note:\n",
168-
"\n",
165+
":::{note}\n",
169166
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
170-
"\n",
171-
"</div>"
167+
":::"
172168
]
173169
},
174170
{
@@ -312,13 +308,9 @@
312308
"source": [
313309
"As well as the model coefficients, we might be interested in the avarage causal impact and average cumulative causal impact.\n",
314310
"\n",
315-
"<div class=\"alert alert-info\">\n",
316-
"\n",
317-
"Note\n",
318-
"\n",
311+
":::{note}\n",
319312
"Better output for the summary statistics are in progress!\n",
320-
"\n",
321-
"</div>"
313+
":::"
322314
]
323315
},
324316
{
@@ -405,13 +397,9 @@
405397
"cell_type": "markdown",
406398
"metadata": {},
407399
"source": [
408-
"<div class=\"alert alert-warning\">\n",
409-
"\n",
410-
"Warning\n",
411-
"\n",
400+
":::{warning}\n",
412401
"Care must be taken with the mean impact statistic. It only makes sense to use this statistic if it looks like the intervention had a lasting (and roughly constant) effect on the outcome variable. If the effect is transient, then clearly there will be a lot of post-intervention period where the impact of the intervention has 'worn off'. If so, then it will be hard to interpret the mean impacts real meaning.\n",
413-
"\n",
414-
"</div>"
402+
":::"
415403
]
416404
},
417405
{

docs/source/notebooks/rd_pymc.ipynb

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
@@ -42,13 +43,9 @@
4243
"cell_type": "markdown",
4344
"metadata": {},
4445
"source": [
45-
"<div class=\"alert alert-info\">\n",
46-
"\n",
47-
"Note:\n",
48-
"\n",
46+
":::{note}\n",
4947
"The `random_seed` keyword argument for the PyMC sampler is not neccessary. We use it here so that the results are reproducible.\n",
50-
"\n",
51-
"</div>"
48+
":::"
5249
]
5350
},
5451
{

0 commit comments

Comments
 (0)