Learn R Programming

astsa (version 2.2)

pre.white: Cross-Correlation Analysis With Automatic Prewhitening

Description

Performs a cross-correlation analysis on two series after prewhitening the first series and filtering the second series accordingly.

Usage

pre.white(series1, series2, diff = FALSE, max.lag = NULL, main = NULL, 
           order.max = NULL, plot = TRUE, ...)

Value

Returns the sample CCF graphic using the prewhitened series unless plot = FALSE. The prewhitened series are returned invisibly.

Arguments

series1, series2

univariate time series

diff

(logical or integer) should the series be differenced prior to the analysis and if more than first order, by how much

max.lag

maximum lag for which to plot the CCF - if NULL, a suitable number is chosen (see details)

main

plot title - if NULL, uses series1 name appended by .w for whitened and series2 name appended by .f for filtered

order.max

maximum order of model to fit (see details)

plot

should the sample CCF be plotted

...

additional graphic arguments

Author

D.S. Stoffer

Details

The first series is prewhitened by fitting a long AR based on AIC and the second series is filtered appropriately. Then a cross-correlation analysis is performed via ccf2. If differencing is specified, both series are differenced the same way prior to the prewhitening. The resulting series are returned invisibly.

The default is no differencing. Differences of order 1 can be set be entering diff = TRUE or diff = 1. If it is necessary to use higher orders, then enter a positive integer (this is rare).

The maximum lag (max.lag) in the CCF graphic defaults (if NULL) to the smaller of 50 and 20% of the sample size.

The maximum order (order.max) for fitting the AR via AIC defaults (if NULL) to the minimum of 30 and 15% of the number of observations.

References

You can find demonstrations of astsa capabilities at FUN WITH ASTSA.

The most recent version of the package can be found at https://github.com/nickpoison/astsa/.

In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.

The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.

Examples

Run this code
pre.white(cmort, part, diff=TRUE, col=4)

Run the code above in your browser using DataLab