Skip to content

Commit 41baf98

Browse files
committed
visualization of predictive distributions against data
1 parent 08a3228 commit 41baf98

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

vignettes/Chapter09.Rmd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,22 @@ q_y <- quantile(y, quants)
220220
221221
knitr::kable(round(t(cbind(q_y, q_t, q_normal)), 3))
222222
```
223+
224+
We conclude by visualizing the data and the predictive distributions.
225+
226+
```{r, echo = -c(1:2)}
227+
if (pdfplots) {
228+
pdf("9-1_4.pdf", width = 10, height = 4)
229+
par(mar = c(2.7, 1.5, 1.5, .1), mgp = c(1.6, .6, 0))
230+
}
231+
par(mfrow = c(1, 2))
232+
grid <- seq(-ceiling(max(abs(y))), ceiling(max(abs(y))), length.out = 50)
233+
hist(y, freq = FALSE, breaks = grid, main = "Histogram and predictive densitites")
234+
lines(density(yf_normal, adjust = 2), col = 4, lty = 1, lwd = 2)
235+
lines(density(yf_t, adjust = 2), col = 2, lty = 2, lwd = 2)
236+
legend("topleft", c("Normal", "Student t"), lty = 1:2, col = c(4,2), lwd = 2)
237+
ts.plot(y, main = "Time series plot and some predictive intervals")
238+
abline(h = q_normal, col = 4, lty = 1, lwd = 2)
239+
abline(h = q_t, col = 2, lty = 2, lwd = 2)
240+
legend("topleft", c("Normal", "Student t"), lty = 1:2, col = c(4,2), lwd = 2)
241+
```

0 commit comments

Comments
 (0)