lpacf.Epan {lpacf}R Documentation

Calculates the lpacf (local partial autocorrelation function) using an Epanechnikov kernel spectral smoother.

Description

This calculates the local partial autocorrelation function for data x based on spectral smoothing using the Epanechnikov kernel. Up to lag.max lags are calculated.

Usage

lpacf.Epan(x, binwidth, lag.max=NULL, filter.number=10, family="DaubLeAsymm", 
    smooth.dev=var, AutoReflect=TRUE, tol=0.1, maxits=5, ABBverbose=0, lapplyfn=lapply,
    allpoints=FALSE, verbose=FALSE, ...)

Arguments

x

The time series you wish to analyze

binwidth

The bandwidth for the spectral smoothing. If the argument is missing or zero then the bandwidth is chosen automatically using the AutoBestBW.Epan function. The smoothing is done using the Epanechnikov kernel in the Epanechnikov function.

lag.max

The maximum lag of pacf required. If this argument is NULL then the maximum lag is computed internally to be floor(10*log10(n)) where n is the length of the series. E.g. if n=512 then the lag.max will be set to 27.

filter.number

The wavelet filter number for helping choose the smoothing binwidth, used only by AutoBestBW.

family

The wavelet family for helping choose the smoothing binwidth, used only by AutoBestBW.

smooth.dev

The type of deviance used by AutoBestBW to smooth an internal wavelet spectral estimate. The usual variance var is a good option, but something like a rescaled mad could be an alternative.

AutoReflect

Mitigate periodic boundary conditions of wavelet transforms by reflecting time series about RHS end before taking transforms (and is undone before returning the answer). Setting this to be TRUE usually dramatically improves the results as the wavelet smoothing is performed using periodic transforms.

tol

Tolerance for golden section search for the best bandwidth used only by AutoBestBW.

maxits

Maximum number of iterations for the golden section search used by AutoBestBW.

ABBverbose

If nonzero prints out informative messages about the progress of the golden section search. Higher integers produce more messages. Setting it to zero suppresses messages.

lapplyfn

Function which applies a specified function to a vector. lapply is default but this argument can be used to replace this by something more efficient, e.g. a parallel version such as mclapply. Note, if you use mclapply then you should set the option mc.cores to something sensible. E.g. I have a quad-core machine, so when I am using the machine myself, alone, I set options(mc.cores=4). If you have many cores on a multicore machine, but with several users, you might want the number of codes to be used by your code to be less than the max to be nice to others.

allpoints

The lpacf is calculated using a window centered on a time point, if allpoints=TRUE then the edges of the data are also estimated (where a smaller, non-centered binwidth is used). Note, if allpoints=TRUE you obtain an estimator for the whole length of the series, but it will be more variable nearer the ends.

verbose

If TRUE then some informative messages are printed, otherwise they're not

...

Other arguments for AutoBestBW.

Details

Calculates the local partial autocorrelation function (lpacf) for 1,...,lag.max lags. See paper in the references for more details. NOTE: Often when local (windowed) estimates are created one assigns the estimated value to the central point in the window. This is the approach we take here when calculating the lacv and lpacf. This differs from the lpacf calculated for the forecastlpacf function which assign the estimated value to the last point in the window.

The function works by using the regular R pacf applied to carefully chosen windows of the original series. Note: code in the forecastlpacf from the forecastLSW package can compute a slightly different version of the localized pacf using a wavelet method.

Value

An object of class lpacf. This is a list with the following components:

the.x

the time coordinates of the localized partial autocorrelations. Call the length of this vector n. These coordinates can be non-integer (usually at halves) even if the original times are at the integers (which is assumed by this function). You can think of these indexing the value of the localized partial autocorrelation centred at these locations.

lpacf

The localized partical autocorrelations. Matrix of dimension n x lag.max containing the lpacf for each time point at lags 1,...,lag.max.

the.vacc

This is TRUE if allpoints=TRUE and FALSE otherwise.

the.x1

If allpoints=TRUE this vector contains the x coordinate (time coordinate) values of the left-hand end of the series that are computed using increasingly reduced numbers of data points.

the.x2

As for the.x1 but for the right-hand end of the series.

vacc

A vector of length two containing the interval of time points for which the localized autocovariance is computed using the largest number of points in the calculation — ie the full binwidth.

binwidth

The smoothing binwidth that was used.

AutoBinWidth

This is TRUE if the binwidth was automatically selected, and FALSE if it was not.

Author(s)

Guy Nason and Rebecca Killick

References

Killick, R., Knight, M. I., Nason, G.P. and Eckley, I. A. (2020) The local partial autocorrelation function and some applications. Electron. J. Statist. 14 (2), 3268-3314. DOI: 10.1214/20-EJS1748.

See Also

lpacf, lpacf.plot, forecastlpacf, plot.lacf, print.lpacf, summary.lpacf

Examples


# first generate a time-varying process
set.seed(1)
x=tvar2sim()

x.lpacf <- lpacf(x)

#
# There are two functions to plot lpacf class objects
#
# One is via the generic function plot which uses plot.lpacf
# the other is a bespoke function lpact.plot. We'll look at
# the generic function first which behaves similarly to the equivalent
# function in the locits package: plot.lacf
#
#
# This plot shows all of the localized partial autocovariances up to lag 27
# which is the default calculated value for this length of time series.
plot(x.lpacf)

#
# In the previous plot, maybe there were too many lags. So, let's restrict to
# five lags and colour them differently.
#
plot(x.lpacf, lags=1:5, lcol=1:5)
#
# By default, the lpacf is not computed for the whole time series range.
# Let's do it for all the points now, and replot.
#
x.lpacf.all <- lpacf(x, allpoints=TRUE)
plot(x.lpacf.all, lags=1:5, lcol=1:5)
#
#
# Suppose we wanted to look at the localized partial autocorrelation at a
# particular time point, using the regular acf-like plot. We can do this by:
#
# We will choose the time point to examine the localized pacf at as 150.
#
plot(x.lpacf, type="acf", the.time=150)

# calculate the lpacf
ans<-lpacf.Epan(x,lag.max=10,filter.number=2,family="DaubExPhase")

# then maybe plot it by lag
lpacf.plot(ans,atLag=1:10,atTime=100)


[Package lpacf version 1.0.1 Index]