Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mwar.ani

Demonstration for “Moving Window Auto-Regression”


Description

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.

Usage

mwar.ani(x, k = 15, conf = 2, mat = matrix(1:2, 2), widths = rep(1, ncol(mat)), 
    heights = rep(1, nrow(mat)), lty.rect = 2, ...)

Arguments

x

univariate time-series (a single numerical vector); default to be sin(seq(0, 2 * pi, length = 50)) + rnorm(50, sd = 0.2)

k

an integer of the window width

conf

a positive number: the confidence intervals are computed as c(ar1 - conf*s.e., ar1 + conf*s.e.)

mat, widths, heights

arguments passed to layout to divide the device into 2 parts

lty.rect

the line type of the rectangles respresenting the moving “windows”

...

other arguments passed to points in the bottom plot (the centers of the arrows)

Details

The AR(1) coefficients are computed by arima.

Value

A list containing

phi

the AR(1) coefficients

L

lower bound of the confidence interval

U

upper bound of the confidence interval

Author(s)

Yihui Xie

References

Robert A. Meyer, Jr. Estimating coefficients that change over time. International Economic Review, 13(3):705-710, 1972.

See Also


animation

A Gallery of Animations in Statistics and Utilities to Create Animations

v2.6
GPL
Authors
Yihui Xie [aut, cre], Christian Mueller [ctb], Lijia Yu [ctb], Weicheng Zhu [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.