Skip to content

Commit 7a0f349

Browse files
committed
Bring stochastic volatility notebook in line with style guide
Fixing dashes in reference entry Removing extra lines from reference bib file
1 parent 58439f0 commit 7a0f349

File tree

3 files changed

+305
-122
lines changed

3 files changed

+305
-122
lines changed

examples/case_studies/stochastic_volatility.ipynb

Lines changed: 268 additions & 117 deletions
Large diffs are not rendered by default.

examples/references.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ @book{hayes2017introduction
148148
year = {2017},
149149
publisher = {Guilford publications}
150150
}
151+
@article{hoffman2014nuts,
152+
title = {The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo},
153+
author = {Hoffman, Matthew and Gelman, Andrew},
154+
year = {2014},
155+
journal = {Journal of Machine Learning Research},
156+
volume = {15},
157+
issue = {1},
158+
pages = {1593--1623},
159+
url = {https://dl.acm.org/doi/10.5555/2627435.2638586}
160+
}
151161
@misc{hogg2010data,
152162
title = {Data analysis recipes: Fitting a model to data},
153163
author = {David W. Hogg and Jo Bovy and Dustin Lang},

myst_nbs/case_studies/stochastic_volatility.myst.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ jupytext:
66
format_version: 0.13
77
jupytext_version: 1.13.7
88
kernelspec:
9-
display_name: Python 3 (ipykernel)
9+
display_name: pymc_env
1010
language: python
11-
name: python3
11+
name: pymc_env
1212
---
1313

14+
(notebook_name)=
1415
# Stochastic Volatility model
1516

17+
:::{post} June 17, 2022
18+
:tags: time series
19+
:category: basic
20+
:author:
21+
:::
22+
1623
```{code-cell} ipython3
1724
import os
1825
@@ -26,15 +33,15 @@ rng = np.random.RandomState(1234)
2633
az.style.use("arviz-darkgrid")
2734
```
2835

29-
Asset prices have time-varying volatility (variance of day over day `returns`). In some periods, returns are highly variable, while in others very stable. Stochastic volatility models model this with a latent volatility variable, modeled as a stochastic process. The following model is similar to the one described in the No-U-Turn Sampler paper, Hoffman (2011) p21.
36+
Asset prices have time-varying volatility (variance of day over day `returns`). In some periods, returns are highly variable, while in others very stable. Stochastic volatility models model this with a latent volatility variable, modeled as a stochastic process. The following model is similar to the one described in the No-U-Turn Sampler paper, {cite:p}`hoffman2014nuts`.
3037

3138
$$ \sigma \sim Exponential(50) $$
3239

3340
$$ \nu \sim Exponential(.1) $$
3441

3542
$$ s_i \sim Normal(s_{i-1}, \sigma^{-2}) $$
3643

37-
$$ log(r_i) \sim t(\nu, 0, exp(-2 s_i)) $$
44+
$$ \log(r_i) \sim t(\nu, 0, \exp(-2 s_i)) $$
3845

3946
Here, $r$ is the daily return series and $s$ is the latent log volatility process.
4047

@@ -182,9 +189,24 @@ axes[1].set_title("Posterior volatility");
182189

183190
## References
184191

185-
1. Hoffman & Gelman. (2011). [The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo](http://arxiv.org/abs/1111.4246).
192+
:::{bibliography}
193+
:filter: docname in docnames
194+
:::
186195

187196
```{code-cell} ipython3
188197
%load_ext watermark
189198
%watermark -n -u -v -iv -w -p aesara,xarray
190199
```
200+
201+
## Authors
202+
203+
+++
204+
205+
* Updated by Abhipsha Das on July 24, 2021 ([pymc-examples#155](https://github.com/pymc-devs/pymc-examples/pull/155))
206+
* Updated by Michael Osthege on June 1, 2022 ([pymc-examples#343](https://github.com/pymc-devs/pymc-examples/pull/343))
207+
* Updated by Christopher Krapu on June 17, 2022 ([pymc-examples#XX](https://github.com/pymc-devs/pymc-examples/pull/XX))
208+
209+
+++
210+
211+
:::{include} ../page_footer.md
212+
:::

0 commit comments

Comments
 (0)