---
title: mwar.ani()
subtitle: Demonstration of Moving Window Auto-Regression
date: '2017-04-04'
slug: mwar-ani
---

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`.
 
```{r demo-a, cache=TRUE, interval=.1}
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')
```

```{r demo-b, cache=TRUE, interval=.1}
## for the data 'pageview'
mwar.ani(pageview$visits, k = 30)
```
