Performs a cross-correlation analysis on two series after prewhitening the first series and filtering the second series accordingly.
pre.white(series1, series2, diff = FALSE, max.lag = NULL, main = NULL,
order.max = NULL, plot = TRUE, ...)
Returns the sample CCF graphic using the prewhitened series unless plot = FALSE
. The prewhitened series are returned invisibly.
univariate time series
(logical or integer) should the series be differenced prior to the analysis and if more than first order, by how much
maximum lag for which to plot the CCF - if NULL, a suitable number is chosen (see details)
plot title - if NULL, uses series1 name appended by .w for whitened and series2 name appended by .f for filtered
maximum order of model to fit (see details)
should the sample CCF be plotted
additional graphic arguments
D.S. Stoffer
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.
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/.
pre.white(cmort, part, diff=TRUE, col=4)
Run the code above in your browser using DataLab