Skip to content

Commit

Permalink
Graph fixes (#317)
Browse files Browse the repository at this point in the history
* Fixed plot titles

* Missing bands
  • Loading branch information
jlperla authored Nov 20, 2024
1 parent 896971a commit 35f50cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
36 changes: 18 additions & 18 deletions lectures/time_series_models/additive_functionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ function plot_martingales(amf, T, npaths = 25)
plot_martingale_paths(T, mpath_mult[(li + 1):ui, :],
mbounds_mult[(LI + 1):UI, :], horline = 1))
plot!(mart_figs[ii + 1],
title = L"Martingale components for many paths of $y_{ii + 1}$")
title = L"Martingale components for many paths of $y_{ii + 1}$",
titlefontsize = 12)
end
return mart_figs
Expand Down Expand Up @@ -594,7 +595,8 @@ function plot_given_paths(T, ypath, mpath, spath, tpath, mbounds, sbounds;
end
plot!(plots[1], seriestype = :hline, [horline], color = :black,
linestyle = :dash, label = "")
plot!(plots[1], title = "One Path of All Variables", legend = :topleft)
plot!(plots[1], title = "One Path of All Variables", legend = :topleft,
titlefontsize = 12)
# plot martingale component
plot!(plots[2], trange, mpath[1, :], color = :magenta, label = "")
Expand All @@ -605,7 +607,8 @@ function plot_given_paths(T, ypath, mpath, spath, tpath, mbounds, sbounds;
label = "")
plot!(plots[2], seriestype = :hline, [horline], color = :black,
linestyle = :dash, label = "")
plot!(plots[2], title = "Martingale Components for Many Paths")
plot!(plots[2], title = "Martingale Components for Many Paths",
titlefontsize = 12)
# plot stationary component
plot!(plots[3], spath[1, :], color = :green, label = "")
Expand All @@ -616,15 +619,17 @@ function plot_given_paths(T, ypath, mpath, spath, tpath, mbounds, sbounds;
label = "")
plot!(plots[3], seriestype = :hline, [horline], color = :black,
linestyle = :dash, label = "")
plot!(plots[3], title = "Stationary Components for Many Paths")
plot!(plots[3], title = "Stationary Components for Many Paths",
titlefontsize = 12)
# plot trend component
if show_trend == true
plot!(plots[4], Matrix(tpath'), color = :red, label = "")
end
plot!(plots[4], seriestype = :hline, [horline], color = :black,
linestyle = :dash, label = "")
plot!(plots[4], title = "Trend Components for Many Paths")
plot!(plots[4], title = "Trend Components for Many Paths",
titlefontsize = 12)
return plots
end
Expand All @@ -640,7 +645,8 @@ function plot_martingale_paths(T, mpath, mbounds;
# plot martingale component
ub = mbounds[2, :]
lb = mbounds[1, :]
#plot!(plt, lb, fillrange = ub, alpha = 0.25, color = :magenta, label = "")
plot!(plt, ub, fillrange = lb, alpha = 0.25, color = :magenta, label = "")
plot!(plt, seriestype = :hline, [horline], color = :black,
linestyle = :dash, label = "")
plot!(plt, trange, Matrix(mpath'), linewidth = 0.25, color = :black,
Expand All @@ -657,7 +663,7 @@ For now, we just plot $y_t$ and $x_t$, postponing until later a description of e
---
tags: [remove-cell]
---
Random.seed!(42);
Random.seed!(43);
```

```{code-cell} julia
Expand Down Expand Up @@ -685,16 +691,16 @@ x, y = simulate(amf.lss, T)
plt_1 = plot()
plt_2 = plot()
plots = [plt_1, plt_2]
# plots = plot(layout = (2, 1))
plot!(plots[1], 1:T, y[amf.nx + 1, :], color = :black, lw = 2, label = "")
plot!(plots[1], title = L"A particular path of $y_t$")
plot!(plots[1], title = L"A particular path of $y_t$",
titlefontsize = 12)
plot!(plots[2], 1:T, y[1, :], color = :green, lw = 2, label = "")
plot!(plots[2], seriestype = :hline, [0], color = :black, lw = 2,
linestyle = :dashdot, label = "")
plot!(plots[2], title = L"Associated path of $x_t$")
# plot(plots)
plot(plots[1], plots[2], layout = (2, 1), size = (700, 500))
plot!(plots[2], title = L"Associated path of $x_t$",
titlefontsize = 12)
plot(plots[1], plots[2], layout = (2, 1), size = (700, 600))
```

```{code-cell} julia
Expand Down Expand Up @@ -933,12 +939,6 @@ $\widetilde M_t$ of the multiplicative decomposition has a peculiar property.

The following simulation of many paths of $\widetilde M_t$ illustrates this property

```{code-cell} julia
---
tags: [remove-cell]
---
Random.seed!(10021987);
```

```{code-cell} julia
plt = plot_martingales(amf, 12000)
Expand Down
11 changes: 5 additions & 6 deletions lectures/time_series_models/multiplicative_functionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ Random.seed!(42);

```{code-cell} julia
# Create the second (wrong) alternative model
amf2 = AMF_LSS_VAR(A = 0.9, B = 1.0, D = 0.55, F = 0.25) # parameters for theta_1 closer to theta_0
# parameters for theta_1 closer to theta_0
amf2 = AMF_LSS_VAR(A = 0.9, B = 1.0, D = 0.55, F = 0.25)
# Get likelihood from each path x^{i}, y^{i}
LLit2 = simulate_likelihood(amf2, Xit, Yit)
Expand Down Expand Up @@ -604,10 +605,10 @@ amc, mmc = simulate_martingale_components(amf_2, 1_000, 5_000)
amcT = amc[:, end]
mmcT = mmc[:, end]
println("The (min, mean, max) of additive Martingale component in period T is")
println("The (min, mean, max) of additive Martingale component in period T:")
println("\t ($(minimum(amcT)), $(mean(amcT)), $(maximum(amcT)))")
println("The (min, mean, max) of multiplicative Martingale component in period T is")
println("The (min, mean, max) of multiplicative Martingale component in period T:")
println("\t ($(minimum(mmcT)), $(mean(mmcT)), $(maximum(mmcT)))")
```

Expand Down Expand Up @@ -708,13 +709,11 @@ dens_to_plot = [Mtilde_t_density(amf_2, t, xmin = 1e-8, xmax = 6.0)
ldens_to_plot = [logMtilde_t_density(amf_2, t, xmin = -10.0, xmax = 10.0)
for t in times_to_plot]
# plot_title = "Densities of M_t^tilda" is required, however, plot_title is not yet
# supported in Plots
plots = plot(layout = (3, 2), size = (600, 800))
for (it, dens_t) in enumerate(dens_to_plot)
x, pdf = dens_t
plot!(plots[it], title = "Density for time (time_to_plot[it])",
plot!(plots[it], title = "Density for time $(times_to_plot[it])",
titlefontsize = 10)
plot!(plots[it], pdf, fillrange = 0, label = "")
end
Expand Down

0 comments on commit 35f50cc

Please sign in to comment.