Skip to content

Commit

Permalink
Multiple updates to v5 (pymc-devs#516)
Browse files Browse the repository at this point in the history
* update notebooks authored by Ben Vincent to v5
  • Loading branch information
drbenvincent authored Feb 2, 2023
1 parent cef367c commit 78f5794
Show file tree
Hide file tree
Showing 20 changed files with 1,688 additions and 1,485 deletions.
495 changes: 260 additions & 235 deletions examples/case_studies/mediation_analysis.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/case_studies/mediation_analysis.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: Python 3 (ipykernel)
display_name: pymc_env
language: python
name: python3
name: pymc_env
---

(mediation_analysis)=
Expand Down Expand Up @@ -182,7 +182,7 @@ with pm.Model() as total_effect_model:
c = pm.Normal("c", mu=0, sigma=1)
σy = pm.HalfCauchy("σy", 1)
μy = iy + c * _x
pm.Normal("yy", mu=μy, sd=σy, observed=y, dims="obs_id")
pm.Normal("yy", mu=μy, sigma=σy, observed=y, dims="obs_id")
```

```{code-cell} ipython3
Expand Down
269 changes: 138 additions & 131 deletions examples/case_studies/moderation_analysis.ipynb

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions examples/case_studies/moderation_analysis.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: pymc-dev-py39
display_name: pymc_env
language: python
name: pymc-dev-py39
name: pymc_env
---

(moderation_analysis)=
Expand Down Expand Up @@ -234,13 +234,13 @@ def model_factory(x, m, y):
x = pm.ConstantData("x", x)
m = pm.ConstantData("m", m)
# priors
β0 = pm.Normal("β0", mu=0, sd=10)
β1 = pm.Normal("β1", mu=0, sd=10)
β2 = pm.Normal("β2", mu=0, sd=10)
β3 = pm.Normal("β3", mu=0, sd=10)
β0 = pm.Normal("β0", mu=0, sigma=10)
β1 = pm.Normal("β1", mu=0, sigma=10)
β2 = pm.Normal("β2", mu=0, sigma=10)
β3 = pm.Normal("β3", mu=0, sigma=10)
σ = pm.HalfCauchy("σ", 1)
# likelihood
y = pm.Normal("y", mu=β0 + (β1 * x) + (β2 * x * m) + (β3 * m), sd=σ, observed=y, dims="obs")
y = pm.Normal("y", mu=β0 + (β1 * x) + (β2 * x * m) + (β3 * m), sigma=σ, observed=y)
return model
```
Expand Down Expand Up @@ -361,6 +361,7 @@ But readers are strongly encouraged to read {cite:t}`mcclelland2017multicollinea
## Authors
- Authored by Benjamin T. Vincent in June 2021
- Updated by Benjamin T. Vincent in March 2022
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
242 changes: 132 additions & 110 deletions examples/causal_inference/difference_in_differences.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ Of course, when using the difference in differences approach for real applicatio

## Authors
- Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in Sept 2022 ([#424](https://github.com/pymc-devs/pymc-examples/pull/424)).
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
460 changes: 242 additions & 218 deletions examples/causal_inference/excess_deaths.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/causal_inference/excess_deaths.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ The bad news of course, is that as of the last data point (May 2022) the number

## Authors
- Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in July 2022.
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
210 changes: 116 additions & 94 deletions examples/causal_inference/interrupted_time_series.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/causal_inference/interrupted_time_series.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ There are of course many ways that the interrupted time series approach could be

## Authors
- Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in October 2022.
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
204 changes: 110 additions & 94 deletions examples/causal_inference/regression_discontinuity.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/causal_inference/regression_discontinuity.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: pymc-dev-py39
display_name: pymc_env
language: python
name: pymc-dev-py39
name: pymc_env
---

(regression_discontinuity)=
Expand Down Expand Up @@ -229,6 +229,7 @@ In this notebook we have merely touched the surface of how to analyse data from

## Authors
- Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in April 2022
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
174 changes: 92 additions & 82 deletions examples/generalized_linear_models/GLM-binomial-regression.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: pymc-dev-py39
display_name: pymc_env
language: python
name: pymc-dev-py39
name: pymc_env
---

(GLM-binomial-regression)=
Expand Down Expand Up @@ -237,6 +237,7 @@ A good introduction to generalized linear models is provided by {cite:t}`roback2
## Authors
- Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in July 2021
- Updated by [Benjamin T. Vincent](https://github.com/drbenvincent) in February 2022
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
872 changes: 480 additions & 392 deletions examples/generalized_linear_models/GLM-simpsons-paradox.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: pymc-dev-py39
display_name: pymc_env
language: python
name: pymc-dev-py39
name: pymc_env
---

(GLM-simpsons-paradox)=
Expand Down Expand Up @@ -544,6 +544,7 @@ If you are interested in learning more, there are a number of other [PyMC exampl
## Authors
* Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in July 2021
* Updated by [Benjamin T. Vincent](https://github.com/drbenvincent) in April 2022
* Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: Python 3.10.6 ('pymc_env')
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down Expand Up @@ -361,6 +361,7 @@ When looking into this topic, I found that most of the material out there focuse
* Authored by [Benjamin T. Vincent](https://github.com/drbenvincent) in May 2021
* Updated by [Benjamin T. Vincent](https://github.com/drbenvincent) in January 2022
* Updated by [Benjamin T. Vincent](https://github.com/drbenvincent) in September 2022
* Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5

+++

Expand Down
147 changes: 63 additions & 84 deletions examples/mixture_models/gaussian_mixture_model.ipynb

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions examples/mixture_models/gaussian_mixture_model.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: pymc-dev-py39
display_name: pymc_env
language: python
name: pymc-dev-py39
name: pymc_env
---

(gaussian_mixture_model)=
Expand Down Expand Up @@ -63,7 +63,7 @@ with pm.Model(coords={"cluster": range(k)}) as model:
"μ",
mu=0,
sigma=5,
transform=pm.distributions.transforms.ordered,
transform=pm.distributions.transforms.univariate_ordered,
initval=[-4, 0, 4],
dims="cluster",
)
Expand Down Expand Up @@ -109,6 +109,7 @@ ax[2].set(title="Group membership", xlabel="x", ylabel="Probability");
- Authored by Abe Flaxman.
- Updated by Thomas Wiecki.
- Updated by [Benjamin T. Vincent](https://github.com/drbenvincent) in April 2022 ([#310](https://github.com/pymc-devs/pymc-examples/pull/310)) to use `pm.NormalMixture`.
- Updated by Benjamin T. Vincent in February 2023 to run on PyMC v5.

+++

Expand Down

0 comments on commit 78f5794

Please sign in to comment.