Skip to content

Commit fba05bd

Browse files
colinpochart2claude
andcommitted
Fix posterior dimensionality wording and tidy Stan code
- info.json: posterior is T-dimensional over (s, nu), not (T+1) - stochastic_volatility.stan: remove empty functions block and stale comments Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 560feed commit fba05bd

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

posterior_database/models/info/stochastic_volatility.info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "stochastic_volatility",
33
"keywords": ["time_series", "stochastic_volatility", "marginalized"],
44
"title": "Stochastic Volatility Model with Marginalized Precision",
5-
"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).",
5+
"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.",
66
"urls": "https://www.jmlr.org/papers/v15/hoffman14a.html",
77
"model_implementations": {
88
"stan": {

posterior_database/models/stan/stochastic_volatility.stan

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
functions {
2-
3-
}
4-
51
data {
62
int<lower=1>T; //number of days
73
vector<lower=0>[T] y; //index values of sp500
84
}
95

106
transformed data {
11-
vector[T-1] log_returns; // log y_i - log y_{i-1} for i = 2, ..., T
7+
vector[T-1] log_returns;
128
for (i in 2:T) {
139
log_returns[i-1] = log(y[i]) - log(y[i-1]);
1410
}
@@ -31,9 +27,7 @@ model {
3127
for (i in 2:T) {
3228
target += student_t_lpdf(log_returns[i-1] | nu, 0, s[i]);
3329
}
34-
35-
// Term from marginalizing out tau analytically:
36-
// target += -((T + 1) / 2.0) * log(0.01 + 0.5 * sum((log s_i - log s_{i-1})^2))
30+
3731
{
3832
real sum_sq = 0;
3933
for (i in 2:T) {

0 commit comments

Comments
 (0)