Move and compute!
Compute the AR(1) coefficient for the data in the window and plot the confidence intervals. Repeat this step as the window moves.
library(animation)
saveHTML({
(nmax = 50)
par(mar = c(2, 3, 1, 0.5), mgp = c(1.5, 0.5, 0))
mwar.ani(lty.rect = 3, pch = 21, col = "red", bg = "yellow",
type = "o")
}, img.name = "mwar_ani", htmlfile = "mwar_ani.html", ani.options(ani.height = 500,
ani.width = 600, outdir = getwd()), title = "Demonstration of Moving Window Auto-Regression",
description = c("Compute the AR(1) coefficient for the data in the\nwindow and plot the confidence intervals. Repeat this step as the\nwindow moves."))
I wish I didn't make serious mistakes in computing the confidence intervals. Would somebody check it for me? Thanks!