Learn R Programming

animation (version 0.2-0)

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, control = ani.control(), ...)

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 [ar1 - conf*s.e., ar1 + conf*s.e.]
control
control parameters for the animation; see ani.control
...
other arguments passed to ani.control

Value

  • A list containing
  • phithe AR(1) coefficients
  • Llower bound of the confidence interval
  • Uupper bound of the confidence interval

Details

The AR(1) coefficients are computed by arima.

References

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

See Also

arima

Examples

Run this code
# moving window along a sin curve 
mwar.ani(interval = 0.3)

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

# HTML animation page
ani.start()
mwar.ani(interval = 0.2, width = 600, height = 500) 
ani.stop()

Run the code above in your browser using DataLab