You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Here, $y$ is the daily return series and $s$ is the latent volatility process.
26
+
# Here, $y$ is the daily return series and $s$ is the latent log volatility process.
27
27
28
28
# <markdowncell>
29
29
@@ -37,12 +37,13 @@
37
37
38
38
n=400
39
39
returns=np.genfromtxt("data/SP500.csv")[-n:]
40
+
returns[:5]
40
41
41
42
# <markdowncell>
42
43
43
44
# Specifying the model in pymc mirrors its statistical specification.
44
45
#
45
-
# However, it is easier to sample the scale of the volatility process innovations, $\sigma$, on a log scale, so we create it using `TransformedVar` and use `logtransform`. `TransformedVar` creates one variable in the transformed space and one in the normal space. The one in the transformed space (here $\text{log}(\sigma) $) is the one over which sampling will occur, and the one in the normal space is the one to use throughout the rest of the model.
46
+
# However, it is easier to sample the scale of the log volatility process innovations, $\sigma$, on a log scale, so we create it using `TransformedVar` and use `logtransform`. `TransformedVar` creates one variable in the transformed space and one in the normal space. The one in the transformed space (here $\text{log}(\sigma) $) is the one over which sampling will occur, and the one in the normal space is the one to use throughout the rest of the model.
46
47
#
47
48
# It takes a variable name, a distribution and a transformation to use.
48
49
@@ -85,7 +86,7 @@ def hessian(point, nusd):
85
86
86
87
# For this model, the full maximum a posteriori (MAP) point is degenerate and has infinite density. However, if we fix `log_sigma` and `nu` it is no longer degenerate, so we find the MAP with respect to the volatility process, 's', keeping `log_sigma` and `nu` constant at their default values.
87
88
#
88
-
# We use [l_bfgs_b](http://en.wikipedia.org/wiki/Limited-memory_BFGS) because it is more efficient for high dimensional functions (`s` has n elements).
89
+
# We use L-BFGS because it is more efficient for high dimensional functions (`s` has n elements).
89
90
90
91
# <codecell>
91
92
@@ -113,7 +114,7 @@ def hessian(point, nusd):
113
114
title(str(s))
114
115
plot(trace[s][::10].T,'b', alpha=.03);
115
116
xlabel('time')
116
-
ylabel('volatility')
117
+
ylabel('log volatility')
117
118
118
119
#figsize(12,6)
119
120
traceplot(trace, model.vars[:-1]);
@@ -122,5 +123,5 @@ def hessian(point, nusd):
122
123
123
124
# ## References
124
125
#
125
-
# 1. Hoffman & Gelman. (2011). The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo. http://arxiv.org/abs/1111.4246
126
+
# 1. Hoffman & Gelman. (2011). [The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo](http://arxiv.org/abs/1111.4246).
0 commit comments