mwar.ani()

Demonstration of Moving Window Auto-Regression

Yihui Xie & Lijia Yu 2017-04-04

This function just fulfills a very naive idea about moving window regression using rectangles to denote the windows and move them, and the corresponding AR(1) coefficients as long as rough confidence intervals are computed for data points inside the windows during the process of moving.

The AR(1) coefficients are computed by arima.

library(animation)
## moving window along a sin curve
ani.options(interval = 0.1, 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")

plot of chunk demo-a

## for the data 'pageview'
mwar.ani(pageview$visits, k = 30)

plot of chunk demo-b