Learn R Programming

kcpRS (version 1.1.1)

runAR: Running Autocorrelations

Description

Extracts the running autocorrelations by sliding a window comprised of wsize time points, and in each window, the autocorrelation for each variable is computed. Each time the window is slid, the oldest time point is discarded and the latest time point is added.

Usage

runAR(data, wsize = 25)

Value

Running autocorrelations time series

Arguments

data

N x v dataframe where N is the no. of time points and v the no. of variables

wsize

Window size

Examples

Run this code
phase1=cbind(rnorm(50,0,1),rnorm(50,0,1)) #phase1: AutoCorr=0
phase2=cbind(rnorm(50,0,1),rnorm(50,0,1))
phase2=filter(phase2,.50, method="recursive") #phase2: AutoCorr=.5
X=rbind(phase1,phase2)
RS=runAR(data=X,wsize=25)
ts.plot(RS, gpars=list(xlab="Window", ylab="Autocorrelation", col=1:2,lwd=2))

Run the code above in your browser using DataLab