@@ -24,8 +24,11 @@ pdfplots <- FALSE # default: FALSE; set this to TRUE only if you like pdf figure
2424par(mgp = c(1.6, .6, 0), mar = c(2.6, 2.6, 2.6, .4), lwd = 1.5)
2525```
2626
27- # Section 7.2
28- ## Figure 7.1
27+ # Section 7.2: Bayesian Learning of (Stationary) Autoregressive Models
28+ ## Section 7.2.2: Exploring stationarity during post-processing
29+
30+ ## Figure 7.1: U.S. GDP data
31+
2932First, we load the data. Because of the extreme outliers during the COVID
3033pandemic, we restrict our analysis to the time before its outbreak.
3134
@@ -146,7 +149,7 @@ regression <- function(y, X, prior = "improper", b0 = 0, B0 = 1, c0 = 0.01,
146149
147150Now we are ready to reproduce the results in the book.
148151
149- ## Example 7.1
152+ ## Example 7.1: AR modeling of the U.S. GDP data
150153
151154We begin by writing a function that sets up the design matrix for an AR($p$)
152155model.
@@ -177,7 +180,7 @@ for (p in 1:4) {
177180}
178181```
179182
180- ## Figure 7.2
183+ ## Figure 7.2: Exploratory model selection
181184Now we plot the draws for the leading coefficient, i.e., the coefficient
182185corresponding to the highest lag in each of the models.
183186
@@ -218,7 +221,8 @@ res_semi_2 <- regression(y, Xy, prior = "semi-conjugate",
218221
219222```
220223
221- ## Figure 7.3
224+ ## Figure 7.3: AR(3) models with improper, semi-conjugate, and conjugate priors
225+
222226We now visualize the posterior of the model parameters under all those priors.
223227
224228``` {r, echo = -c(1:3), fig.height = 12}
@@ -266,7 +270,7 @@ for (i in 1:5) {
266270We reuse the AR($p$) models under the improper prior from above to explore
267271stationarity for $p = 1, 2, 3$.
268272
269- ## Figure 7.4
273+ ## Figure 7.4: Checking stationarity conditions for the GDP data
270274
271275``` {r, echo = -c(1:2), fig.width = 9, fig.height = 3}
272276if (pdfplots) {
@@ -300,15 +304,15 @@ data("inflation", package = "BayesianLearningCode")
300304
301305First, we plot the data and its empirical autocorrelation function.
302306
303- ## Figure 7.5
307+ ## Figure 7.5: EU inflation data
304308
305309``` {r, echo = -c(1:2)}
306310if (pdfplots) {
307311 pdf("7-2_5.pdf", width = 12, height = 5)
308312 par(mar = c(2.6, 1.5, 1.5, .1), mgp = c(1.5, .5, 0), lwd = 1.5)
309313}
310314par(mfrow = c(1,2))
311- ts.plot(inflation, main = "EU Inflation ")
315+ ts.plot(inflation, main = "EU inflation ")
312316acf(inflation, main = "")
313317title("Empirical autocorrelation function")
314318```
@@ -325,7 +329,7 @@ for (p in 1:3) {
325329}
326330```
327331
328- ## Figure 7.6
332+ ## Figure 7.6: Checking stationarity conditions for the EU inflation data
329333
330334``` {r, echo = -c(1:2), fig.width = 9, fig.height = 3}
331335if (pdfplots) {
0 commit comments