Add stochastic volatility model from Hoffman & Gelman 2014#326
Add stochastic volatility model from Hoffman & Gelman 2014#326colinpochart2 wants to merge 16 commits into
Conversation
|
Excellent! @JTorgander could you do a review? |
| } | ||
|
|
||
| // Term from marginalizing out tau analytically: | ||
| // target += -((T + 1) / 2.0) * log(0.01 + 0.5 * sum((log s_i - log s_{i-1})^2)) |
There was a problem hiding this comment.
This line can be removed
| functions { | ||
|
|
||
| } | ||
|
|
There was a problem hiding this comment.
This block can be removed
| target += -0.01 * s[1]; | ||
|
|
||
| // Likelihood: (log y_i - log y_{i-1}) / s_i ~ t_nu | ||
| // Add -log(s_i) for each term because of the Jacobian of standardization. |
There was a problem hiding this comment.
Where is this happening in the code?
| } | ||
|
|
||
| transformed data { | ||
| vector[T-1] log_returns; // log y_i - log y_{i-1} for i = 2, ..., T |
There was a problem hiding this comment.
This comment can be removed.
There was a problem hiding this comment.
I think we need to include information about the data source, time range etc
| "name": "stochastic_volatility", | ||
| "keywords": ["time_series", "stochastic_volatility", "marginalized"], | ||
| "title": "Stochastic Volatility Model with Marginalized Precision", | ||
| "description": "Stochastic volatility model from Hoffman & Gelman (2014, NUTS paper, p. 1614-1615). Daily log-returns follow a Student-t distribution with time-varying scale s_i. The log-scale follows a Gaussian random walk with precision tau, which is marginalized analytically. Resulting posterior is (T+1)-dimensional over (s, nu).", |
There was a problem hiding this comment.
| "description": "Stochastic volatility model from Hoffman & Gelman (2014, NUTS paper, p. 1614-1615). Daily log-returns follow a Student-t distribution with time-varying scale s_i. The log-scale follows a Gaussian random walk with precision tau, which is marginalized analytically. Resulting posterior is (T+1)-dimensional over (s, nu).", | |
| "description": "Stochastic volatility model from Hoffman & Gelman (2014, NUTS paper, p. 1614-1615). Daily log-returns follow a Student-t distribution with time-varying scale s_i. The log-scale follows a Gaussian random walk with precision tau, which is marginalized analytically. Resulting posterior is T-dimensional over (s, nu), where T is the number of data points.", |
There was a problem hiding this comment.
It is a bit confusing to the user that the raw data has 3021 data points whereas the json data file 3000.
There was a problem hiding this comment.
I think it makes more sense to store this data under the name sp500_[time-range]_T and then name the posterior sp500_[time-range]_T-stochastic_...
Co-authored-by: JTorgander <55882444+JTorgander@users.noreply.github.com>
- info.json: posterior is T-dimensional over (s, nu), not (T+1) - stochastic_volatility.stan: remove empty functions block and stale comments
fba05bd to
bac96c0
Compare
Co-authored-by: JTorgander <55882444+JTorgander@users.noreply.github.com>
Co-authored-by: JTorgander <55882444+JTorgander@users.noreply.github.com>
…_volatility.json Co-authored-by: JTorgander <55882444+JTorgander@users.noreply.github.com>
Adds the stochastic volatility model from Hoffman & Gelman (2014, NUTS paper).
PS: reference posterior draws are not yet included - the HMC run is computationally demanding. Happy to follow
maintainer guidance on the sampling configuration.