prewhiten: Prewhiten a Bivariate Time Series, and Compute and Plot Their...

Description Usage Arguments Value Author(s) Examples

View source: R/prewhiten.R

Description

The bivariate time series are prewhitened according to an AR model fitted to the x-component of the bivariate series. Alternatively, if an ARIMA model is provided, it will be used to prewhiten both series. The CCF of the prewhitened bivariate series is then computed and plotted.

Usage

1
prewhiten(x, y, x.model = ar.res,ylab="CCF", ...)

Arguments

x

first component series

y

second component series

x.model

an ARIMA model; if provided, it is used to prewhiten both series. Otherwise, an AR model is fitted to the x-series and used to prewhiten both series.The AR order is chosen by minimizing the AIC and the fit carried out by the ar.ols function.

ylab

label of y-axis; default is "CCF"

...

additional parameters to be passed to the ar.ols and the ccf function.

Value

A list containing the following components:

ccf

Output from the ccf function on the prewhitened data.

ar

The AR model fit to the x-series, or x.model if it is provided.

Author(s)

Kung-Sik Chan

Examples

1
2
3
4
5
6
7
8
9
data(milk)
data(electricity)
milk.electricity=ts.intersect(milk,log(electricity))
plot(milk.electricity,yax.flip=TRUE,main='') 
ccf(as.numeric(milk.electricity[,1]),as.numeric(milk.electricity[,2]),
main='milk & electricity',ylab='CCF')
me.dif=ts.intersect(diff(diff(milk,12)),diff(diff(log(electricity),12)))
prewhiten(as.numeric(me.dif[,1]),as.numeric(me.dif[,2]),
,ylab='CCF' )

Example output

Loading required package: leaps
Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-17. For overview type 'help("mgcv-package")'.
Loading required package: tseries

Attaching package: 'TSA'

The following objects are masked from 'package:stats':

    acf, arima

The following object is masked from 'package:utils':

    tar

TSA documentation built on July 2, 2018, 1:04 a.m.