WCC {W2CWM2C} | R Documentation |
Wavelet cross-correlation (bivariate case).
Description
The WCC
function (bivariate case) computes the wavelet
cross correlation using the spin.correlation function
of the waveslim package for two time series, and presents
the result as a plot that reduce the number of plots of the
classical function spin.correlation. The heatmap plot is
built using the colorspace package and can be displayed
in the screen or can be saved as PNG, JPG, PDF or EPS.
Usage
WCC(inputDATA, Wname, J, lmax, device="screen", filename,
Hfig, WFig, Hpdf, Wpdf)
Arguments
inputDATA |
A couple of time series as a ts object (please, check the ts manual to get more information about the ts function in R). |
Wname |
The wavelet function or filter to use in the decomposition. |
J |
Specifies the depth of the decomposition. |
lmax |
The maximum lag. |
device |
The type of the output device (by default the option is “screen”, and the other options are “jpg”, “png”, “eps” and “pdf”). |
filename |
The output filename. |
Hfig |
The height of the 'jpg' or 'png' image. |
WFig |
The width of the 'jpg' or 'png' image. |
Hpdf |
The height of the 'eps' or 'pdf'. |
Wpdf |
The width of the 'eps' or 'pdf'. |
Details
The WCC
function compute the wavelet cross-correlation
between two time series and plot the results in a single heatmap
plot (please, look at Figure 5 in Polanco-Martinez and Fernandez-Macho
2014). The WCC code is based on the spin.correlation
routine from Brandon Whitcher's waveslim R package Version:
1.7.1, which is based mainly on wavelet methodology developed by
Whitcher, B., P. Guttorp and D.B. Percival (2000) and Gencay, Selcuk
and Whitcher (2001).
Value
Output:
Output plot: screen or 'filename + .png, .jpg, .eps or .pdf'.
returns.cross.cor: a matrix with the WCC values.
Note
Needs waveslim package to calculate modwt, brick.wall and spin.correlation and also needs the colorspace package to plot the heatmaps.
Author(s)
Josue M. Polanco-Martinez (a.k.a. jomopo).
BC3 - Basque Centre for Climate Change, Bilbao, Spain.
Web1: https://scholar.google.es/citations?user=8djLIhcAAAAJ&hl=en.
Web2: https://www.researchgate.net/profile/Josue_Polanco-Martinez.
Email: josue.m.polanco@gmail.com.
References
Gencay, R., F. Selcuk and B. Whitcher (2001). An
Introduction to Wavelets and Other Filtering Methods in
Finance and Economics, Academic Press.
Ihaka, R., Murrell, P., Hornik, K., Fisher, J. C. and Zeileis, A.
(2012). colorspace: Color Space Manipulation. R package version
1.2.0, The Comprehensive R Archive Network (CRAN), <URL: https://cran.r-project.org/package=colorspace>.
Polanco-Martinez, J. and J. Fernandez-Macho (2014). The
package 'W2CWM2C': description, features and applications.
Computing in Science & Engineering, 16(6):68–78.
doi: 10.1109/MCSE.2014.96.
Polanco-Martinez, J. M. and Abadie, L. M. (2016). Analyzing
crude oil spot price dynamics versus long term future prices: A
wavelet analysis approach. Energies, 9(12), 1089.
doi: 10.3390/en9121089.
Whitcher, B., P. Guttorp, and D.B. Percival (2000). Wavelet analysis of
covariance with application to atmospheric time series.
Journal of Geophysical Research - Atmospheres, 105(D11):941–962.
doi: 10.1029/2000JD900110.
Whitcher, B. (2012). waveslim: Basic wavelet routines for one-,
two- and three-dimensional signal processing. R package version 1.7.1,
The Comprehensive R Archive Network (CRAN),
<URL: https://cran.r-project.org/package=waveslim>.
Examples
## Figure 5 (Polanco-Martinez and Fernandez-Macho 2014)
library("colorspace")
library("waveslim")
library("W2CWM2C")
data(dataexample)
#:: Transforms to log returns using: ln(t + deltat) - ln(t).
#:: The application in this example uses stock market
#:: indexes (it is common to use log returns instead of
#:: raw data). Other kinds of pre-processing data are possible.
dataexample <- dataexample[-1] #remove the dates!
DAXCAC <- dataexample[,c(3,4)]
lrdatex <- apply(log(DAXCAC), 2, diff)
inputDATA <- ts(lrdatex, start=1, frequency=1)
Wname <- "la8"
J <- 8
lmax <- 30
compWCC <- WCC(inputDATA, Wname, J, lmax, device="screen", NULL,
NULL, NULL, NULL, NULL)