@@ -240,16 +240,13 @@ df <- data.frame(
240240 time = 1:N
241241)
242242
243- # save plot labels to reuse them
244- plot_labs <- labs(
245- y = "Water Level (ft)",
246- x = "Year",
247- title = "Water Level in Lake Huron (1875-1972)"
248- )
249-
250243ggplot(df, aes(x = year, y = y)) +
251244 geom_point(size = 1) +
252- plot_labs
245+ labs(
246+ y = "Water Level (ft)",
247+ x = "Year",
248+ title = "Water Level in Lake Huron (1875-1972)"
249+ )
253250```
254251
255252The above plot shows rather strong autocorrelation of the time-series as well as
@@ -259,12 +256,11 @@ We can specify an AR(4) model for these data using the **brms** package as
259256follows:
260257
261258``` {r fit, results = "hide"}
262- control <- list(adapt_delta = 0.99)
263259fit <- brm(
264260 y ~ ar(time, p = 4),
265261 data = df,
266262 prior = prior(normal(0, 0.5), class = "ar"),
267- control = control ,
263+ control = list(adapt_delta = 0.99) ,
268264 seed = SEED,
269265 chains = CHAINS
270266)
@@ -284,8 +280,12 @@ preds <- cbind(
284280ggplot(cbind(df, preds), aes(x = year, y = Estimate)) +
285281 geom_smooth(aes(ymin = Q5, ymax = Q95), stat = "identity", size = 0.5) +
286282 geom_point(aes(y = y)) +
287- labs(subtitle = "Mean (blue) and 90% predictive intervals (gray) vs. observed data (black)") +
288- plot_labs
283+ labs(
284+ y = "Water Level (ft)",
285+ x = "Year",
286+ title = "Water Level in Lake Huron (1875-1972)",
287+ subtitle = "Mean (blue) and 90% predictive intervals (gray) vs. observed data (black)"
288+ )
289289```
290290
291291To allow for reasonable predictions of future values, we will require at least
0 commit comments