covIwrap: A wrapper for the covI function.

covIwrapR Documentation

A wrapper for the covI function.

Description

Computation of the covI function is intensive. This function permits values of covI to be stored in an object, and then if these values are requested again the values can be obtained from a store rather than being computed from scratch.

Usage

covIwrap(S, m, n, ll, storewrap, P)

Arguments

S

Same argument as for covI, a spectral estimate (for a stationary series).

m

The same argument as in covI.

n

The same argument as in covI.

ll

The same argument as in covI.

storewrap

A list. On first call to this function the user should supply storewrap=NULL. This causes the function to initialize the storage. On every return from this function the storewrap component should be extracted from the list and then this storewrap component should be resupplied to any future calls to this function. In this way the function has access to previously computed values.

P

Same argument as in covI. An autocorrelation wavelet computed using the PsiJ function in wavethresh.

Details

Note: covIwrap could be removed from the function tree altogether. I.e. varip2 could call covI directly. However, covIwrap considerably improves the efficiency of the algorithm as it stores intermediate calculations that can be reused rather than being computed repeatedly.

Value

A list containing the following components:

ans

The appropriate covariance

storewrap

A list containing information about all previously computed covariances. This list should be supplied as the storewrap argument to any future calls of this function, so if the same covariance is requested it can be returned from storewrap and not computed again.

Author(s)

Guy Nason.

References

Nason, G.P. (2013) A test for second-order stationarity and approximate confidence intervals for localized autocovariances for locally stationary time series. J. R. Statist. Soc. B, 75, 879-904. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/rssb.12015")}

See Also

varip2, covI

Examples

P1 <- PsiJ(-5, filter.number=1, family="DaubExPhase")
#
# First call to covIwrap
#
ans <- covIwrap(S=c(1/2, 1/4, 1/8, 1/16, 1/32), m=1, n=3, ll=5,
    storewrap=NULL, P=P1)
#
# Make sure you keep the storewrap component.
#
my.storewrap <- ans$storewrap
#
# What is the answer?
#
ans$ans
#[1] 0.8430809
#
# Issue next call to covIwrap: but storewrap argument is now the one we stored.
#
ans <- covIwrap(S=c(1/2, 1/4, 1/8, 1/16, 1/32), m=1, n=3, ll=5,
    storewrap=my.storewrap, P=P1)
#
# This call will reuse the stored value. However, if you change any of the
# arguments then the store won't be used.


locits documentation built on Sept. 8, 2023, 5:07 p.m.