Skip to content

Commit 0dd63cd

Browse files
committed
compute residuals and visualize them, alongside their ACFs
1 parent d382ce4 commit 0dd63cd

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

vignettes/Chapter08.Rmd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,3 +1926,21 @@ for (m in 1:(burnin + M)) {
19261926
```
19271927

19281928
We can again compute draws of the predicted values and the residuals.
1929+
1930+
```{r, echo = -c(1:2)}
1931+
if (pdfplots) {
1932+
pdf("8-3_6.pdf", width = 5, height = 5)
1933+
}
1934+
par(mfrow = c(2, 2), mar = c(2.5, 1.5, 1.5, .5), mgp = c(1.5, .5, 0), lwd = 1.5)
1935+
preds <- tcrossprod(X, betas)
1936+
us <- as.numeric(y) - preds
1937+
epss <- us[-1, ] - t(phis * t(us[-nrow(us), ]))
1938+
plot(as.numeric(tim), rowMeans(us), type = "l", xlab = "Time",
1939+
main = "Mean residuals")
1940+
acf(rowMeans(us))
1941+
title("Estimated ACF")
1942+
plot(as.numeric(tim), c(NA, rowMeans(epss)), type = "l", xlab = "Time",
1943+
main = "Mean residuals of residuals")
1944+
acf(rowMeans(epss))
1945+
title("Estimated ACF")
1946+
```

0 commit comments

Comments
 (0)