Version: | 2.2 |
Date: | 2021-01-07 |
Title: | A Graphical Tool for Wavelet (Cross) Correlation and Wavelet Multiple (Cross) Correlation Analysis |
Description: | Set of functions that improves the graphical presentations of the functions: wave.correlation and spin.correlation (waveslim package, Whitcher 2012) and the wave.multiple.correlation and wave.multiple.cross.correlation (wavemulcor package, Fernandez-Macho 2012b). The plot outputs (heatmaps) can be displayed in the screen or can be saved as PNG or JPG images or as PDF or EPS formats. The W2CWM2C package also helps to handle the (input data) multivariate time series easily as a list of N elements (times series) and provides a multivariate data set (dataexample) to exemplify its use. A description of the package was published in a scientific paper: Polanco-Martinez and Fernandez-Macho (2014), <doi:10.1109/MCSE.2014.96>. |
Depends: | R (≥ 2.14.1), waveslim, wavemulcor, colorspace |
URL: | https://github.com/jomopo/W2CWM2C |
Author: | Josue M. Polanco-Martinez
|
Maintainer: | Josue M. Polanco-Martinez <josue.m.polanco@gmail.com> |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Repository: | CRAN |
LazyLoad: | yes |
Packaged: | 2021-01-08 11:36:23 UTC; jomopo |
Date/Publication: | 2021-01-08 16:20:06 UTC |
NeedsCompilation: | no |
W2CWM2C: a graphical tool for wavelet (cross) correlation and wavelet multiple (cross) correlation analysis
Description
The W2CWM2C package is a set of functions that improves the graphical presentations of the functions 'wave.correlation' and 'spin.correlation' (wavelet cross correlation) (waveslim package, Whitcher 2012) and the 'wave.multiple.correlation' and 'wave.multiple.cross.correlation' (wavemulcor package, Fernandez-Macho 2012b). The plot outputs (heatmaps) can be displayed in the screen or can be saved as PNG or JPG images or as PDF or EPS formats. The W2CWM2C package also helps to handle the (input data) multivariate time series easily as a list of N elements (times series) and provides a multivariate data set (dataexample) to exemplify its use. A description of the package was published by Polanco-Martinez and Fernandez-Macho (2014), <doi:10.1109/MCSE.2014.96>.
Details
Package: | W2CWM2C |
Type: | Package |
Version: | 2.2 |
Date: | 2021-01-07 |
License: | GPL (>= 2) |
LazyLoad: | yes |
The W2CWM2C package contains four functions: (1) WC
that
performs and plots the wavelet correlation for the bivariate case, (2)
WCC
that performs and plots the wavelet cross correlation
for the bivariate case, (3) WMC
that performs and plots
the wavelet multiple correlation for the multivariate case, and
4) WMCC
that performs and plots the wavelet multiple cross
correlation for the multivariate case.
Note
Dependencies: waveslim, wavemulcor and colorspace.
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
Acknowledgement:
I am thankful to Jan de Leeuw and Achim Zeileis for suggesting the use
of the R package colorspace. I am also thanks to Debojyoti Das,
John Garrigan, Peterson Owusu Junior, Rim Ibrahim, and Ato Wilberforce
for reporting some bugs found in my W2CWM2C package. The author
acknowledges to the SEPE (Spanish Public Service of Employment)
for its funding support.
References
Fernandez-Macho, J. (2012a). Wavelet multiple correlation and
cross-correlation: A multiscale analysis of Euro zone stock
markets. Physica A: Statistical Mechanics and its Applications,
391(4):1097–1104. doi: 10.1016/j.physa.2011.11.002.
Fernandez-Macho, J. (2012b). wavemulcor: Wavelet routine for
multiple correlation. R package version 1.2, The Comprehensive R
Archive Network (CRAN), <URL: https://cran.r-project.org/package=wavemulcor>.
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 (2000). Percival. 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>.
Zeileis A, Hornik K, Murrell P (2009). Escaping RGBland: Selecting Colors for Statistical Graphics. Computational Statistics & Data Analysis, 53, 3259–3270. doi: 10.1016/j.csda.2008.11.033.
Wavelet correlation (bivariate case) pairwise comparisons.
Description
The WC
function (bivariate case) computes the wavelet
correlation by means of the function wave.-correlation of
the waveslim package to several time series, makes a
pairwise comparisons and plot the pairwise wavelet correlations in
descending order as a single heatmap using the colorspace
package. The input data are multivariate time series and WC
function only tackle arrays with N x C (elements x columns, where the
number of columns are between 2 and 7) dimensions.
Usage
WC(inputDATA, Wname, J, device="screen", filename,
Hfig, WFig, Hpdf, Wpdf)
Arguments
inputDATA |
An array of multivariate 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. |
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 WC
function compute the wavelet correlation among
time series and plots the results in a single heatmap plot
(which can be displayed in the screen or can be saved as
PNG, JPG, PDF or EPS) showing the WC values as a table (please,
look at Figure 3 in Polanco-Martinez and Fernandez-Macho 2014).
The WC
code is based on the wave.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'.
wavcor.modwtsDAT: matrix with as many rows as levels in
the wavelet transform object. The first column provides the
point estimate for the wavelet correlation followed by the lower
and upper bounds from the confidence interval.
to3DpL: A matrix (the matrix table added in the WC plot) with a J (number of wavelet scales) X C (the number of pairwise comparisons) dimensions, which are in descending order taking into account the sum of the wavelet correlation coefficients for all (J) wavelet scales.
Note
Needs waveslim package to calculate modwt, brick.wall and the wave.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.
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 3 (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 dates!
dataexample <- dataexample[,1:5]
lrdatex <- apply(log(dataexample), 2, diff)
inputDATA <- ts(lrdatex, start=1, frequency=1)
#Input parameters
Wname <- "la8"
J <- 8
compWC <- WC(inputDATA, Wname, J, device="screen", NULL,
NULL, NULL, NULL, NULL)
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)
Wavelet multiple correlation (multivariate case).
Description
The WMC
function generates a plot to the wavelet
routine for multiple correlation
(wave.multiple.correlation)
from the wavemulcor package (Fernandez-Macho 2012b).
The WMC
plot output can be displayed in the screen
(by default) or can be saved as PNG, JPG, PDF or EPS. Furthermore,
it also provides a way to handle multivariate time series easily as
a list of N elements (time series).
Usage
WMC(inputDATA, Wname, J, 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. |
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 WMC
function helps to make and save easily the plot of the
multiple correlation routine
(wave.multiple.correlation) of the
wavemulcor package (Fernandez-Macho 2012b). The WMC
function also helps to manage easily multivariate time series to use
the Wavelet multiple correlation routine.
Value
Output:
Output plot: screen or 'filename + .png, .jpg, .eps or .pdf'.
Output data: The same list of elements of the funtion wave.multiple.correlation of the wavemulcor package (Fernandez-Macho 2012b).
Note
Needs wavemulcor (to compute the wave.multiple.correlation) and waveslim packages (to compute the modwt and the brick.wall).
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
Fernandez-Macho, J. (2012a). Wavelet multiple correlation and
cross-correlation: A multiscale analysis of Euro zone stock
markets. Physica A: Statistical Mechanics and its Applications,
391(4):1097–1104. doi: 10.1016/j.physa.2011.11.002.
Fernandez-Macho, J. (2012b). wavemulcor: Wavelet routine for
multiple correlation. R package version 1.2, The Comprehensive R
Archive Network (CRAN), <URL: https://cran.r-project.org/package=wavemulcor>.
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.
Examples
# This example is the wavelet multiple correlation (WMC) version of
# the Figure 7 in Polanco-Martinez and Fernandez-Macho (2014).
library("wavemulcor")
library("W2CWM2C")
data(dataexample)
#:: Transform 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!
dataexample <- dataexample[,1:5]
lrdatex <- apply(log(dataexample), 2, diff)
inputDATA <- ts(lrdatex, start=1, frequency=1)
#Input parameters
Wname <- "la8"
J <- 8
compWMC <- WMC(inputDATA, Wname, J, device="screen", NULL,
NULL, NULL, NULL, NULL)
Wavelet multiple cross-correlation (multivariate case).
Description
The WMCC
function (multivariate case) computes the wavelet
multiple cross correlation by means of the function
wave.multiple.cross.correlation from the wavemulcor
package (Fernandez-Macho 2012b) and present the result as a novel
plot that reduce the number of plots of the classical function
wave.multiple.cross.correlation. The WMCC
plot output
can be displayed in the screen (by default) or can be saved as PNG,
JPG, PDF or EPS. The WMCC
function also provides a way
to handle multivariate time series easily as a list of N elements
(time series).
Usage
WMCC(inputDATA, Wname, J, lmax, device="screen", filename,
Hfig, WFig, Hpdf, Wpdf)
Arguments
inputDATA |
An array of multivariate 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 WMCC
function compute the wavelet multiple
cross correlation using the function
wave.multiple.cross.correlation from the wavemulcor
package (Fernandez-Macho 2012b), but the WMCC
function incorporates some graphical improvements (please, look at
Figure 7 in Polanco-Martinez and Fernandez-Macho 2014), such as
the reduction of the number of plots to present the results of the
function wave.multiple.cross.correlation.
Value
Output:
Output plot: screen or 'filename + .png, .jpg, .eps or .pdf'.
Output data: The same list of elements of the function wave.multiple.cross.correlation of the wavemulcor package (Fernandez-Macho 2012b).
Note
Needs wavemulcor (to compute the wave.multiple.cross.correlation) and waveslim packages (to compute the modwt and the brick.wall) 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
Fernandez-Macho, J. (2012a). Wavelet multiple correlation and
cross-correlation: A multiscale analysis of euro zone stock
markets. Physica A: Statistical Mechanics and its Applications,
391(4):1097–1104. doi: 10.1016/j.physa.2011.11.002.
Fernandez-Macho, J. (2012b). wavemulcor: Wavelet routine for
multiple correlation. R package version 1.2, The Comprehensive R
Archive Network (CRAN), <URL: https://cran.r-project.org/package=wavemulcor>.
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.
Examples
library("colorspace")
library("wavemulcor")
library("W2CWM2C")
data(dataexample)
#:: Figure 7 (Polanco-Martinez and Fernandez-Macho (2014).
#:: Transform 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!
lrdatex <- apply(log(dataexample), 2, diff)
inputDATA <- ts(lrdatex, start=1, frequency=1)
Wname <- "la8"
J <- 8
lmax <- 30
compWCC <- WMCC(inputDATA, Wname, J, lmax, device="screen", NULL,
NULL, NULL, NULL, NULL)
Stock market indexes (daily closing prices).
Description
The data set dataexample contains seven European stock market indexes (daily closing prices): FTSE MIB30 (Italy), IBEX35 (Spain), DAX30 (Germany), CAC40 (France), AEX25 (Netherlands), ATX20 (Austria) and NBEL20 (Belgium) spanning from January 2, 2004 to June 29, 2012. In order to cope with the different official holidays, we have adjusted the raw indices data, carrying forward the closing price from the last working day before each of these holidays.
Usage
data(dataexample)
Format
A list containing 2216 elements and 7 variables