Learn R Programming

costat (version 1.1-1)

localvar: Compute the time-localized (unconditional) variance for a time series

Description

Compute the time localized variance from an evolutionary wavelet spectrum of a time series

Usage

localvar(spec)

Arguments

spec
An evolutionary wavelet spectrum, such as that computed by ewspec in WaveThresh.

Value

  • A vector representing the local variance estimate at successive times.

Details

One can compute the local variance of a time series by first computing its evolutionary wavelet spectrum, e.g., by using ewspec, and then applying localvar on the S component of that returned by ewspec.

Can also be used on the output of ewcrossspec.

References

`Costationary and stationarity tests for stock index returns' by Car dinali and Nason, 2008, University of Bristol Technical Report 08:08.

See Also

ewspec

Examples

Run this code
#
# Let's look at a iid standard normal sequence, variance should be 1, always
# for all times.
#
z <- rnorm(1024)
#
# Note, in the following I use var as the method of deviance estimation,
# as described in the help there it can be more accurate when transformations
# are not used.
#
z.ews <- ewspec(z, smooth.dev=var)
#
# Compute the local variance
#
z.lv <- localvar(z.ews)
#
# Plot the local variance against time
#
ts.plot(z.lv)
#
# Should be around 1. Note, the vertical scale of the plot might be
# deceptive, as R plots expand the function to the maximum available
# space. If you look again it should be quite close to 1 (e.g. on the
# example I am looking at now the variance is within +/- 0.15 of 1.
#

Run the code above in your browser using DataLab