Wave Mul Cor
Wave Mul Cor
Wave Mul Cor
June 8, 2018
Title Wavelet Routines for Global and Local Multiple Correlation
Version 2.2.1
Description Wavelet routines that calculate single sets of
wavelet multiple correlations (WMC) and cross-correlations (WMCC)
out of n variables.
They can later be plotted in single graphs, as an alternative to trying
to make sense out of several sets of wavelet correlations or
wavelet cross-correlations.
The code is based on the calculation, at each wavelet scale, of the
square root of the coefficient of determination in a linear combination
of variables for which such coefficient of determination is a maximum.
The code provided here is based on the wave.correlation routine in
Brandon Whitcher's waveslim R package Version: 1.6.4, which in turn is
based on wavelet methodology developed in Perci-
val and Walden (2000) <DOI:10.1017/CBO9780511841040>;
Gençay, Selçuk and Whitcher (2002) <DOI:10.1016/B978-012279670-8.50013-6> and others.
Version 2 incorporates wavelet local multiple correlations (WLMC).
These are like the previous global WMC but consisting in one
single set of multiscale correlations along time. That is, at each time
t, they are calculated by letting a window of weighted wavelet
coefficients around t move along time. Six weight functions are provided.
Namely, the uniform window, Cleveland's tricube window, Epanechnikov's
parabolic window, Bartlett's triangular window and Wendland's truncated
power window and the Gaussian window.
Version 2.2 incorporates an auxiliary function that calculates local
multiple correlations (LMC). They are calculated by letting move along time
a window of weighted time series values around t. Any of the six weight
functions mentioned above can be used.
License GPL (>= 2)
Depends R (>= 3.4.0), waveslim (>= 1.7.5)
Suggests plot3D
Encoding UTF-8
LazyData true
RoxygenNote 6.0.1
1
2 local.multiple.correlation
NeedsCompilation no
Author Javier Fernandez-Macho [aut, cre]
Maintainer Javier Fernandez-Macho <javier.fernandezmacho@ehu.es>
Repository CRAN
Date/Publication 2018-06-08 21:32:58 UTC
R topics documented:
local.multiple.correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
wave.local.multiple.correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
wave.multiple.correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
wave.multiple.cross.correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
xrand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
xrand1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
xrand2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Index 15
local.multiple.correlation
Routine for local multiple correlation
Description
Produces an estimate of the multiscale local multiple correlation (as defined below) along with
approximate confidence intervals.
Usage
local.multiple.correlation(xx, M, window="gauss", p = .975, ymaxr=NULL)
Arguments
xx A list of n (multiscaled) time series, usually the outcomes of dwt or modwt, i.e.
xx <- list(v1.modwt.bw, v2.modwt.bw, v3.modwt.bw)
M length of the weight function or rolling window.
window type of weight function or rolling window. Six types are allowed, namely the
uniform window, Cleveland or tricube window, Epanechnikov or parabolic win-
dow, Bartlett or triangular window, Wendland window and the gaussian window.
The letter case and length of the argument are not relevant as long as at least the
first four characters are entered.
p one minus the two-sided p-value for the confidence interval, i.e. the cdf value.
ymaxr index number of the variable whose correlation is calculated against a linear
combination of the rest, otherwise at each wavelet level lmc chooses the one
maximizing the multiple correlation.
local.multiple.correlation 3
Details
The routine calculates a time series of multiple correlations out of n variables. The code is based
on the calculation of the square root of the coefficient of determination in that linear combination
of locally weighted values for which such coefficient of determination is a maximum.
Value
List of four elements:
val: vector with as many rows as observations providing the point estimates for the
local multiple correlation.
lo: vector with as many rows as observations providing the lower bounds from the
confidence interval.
up: vector with as many rows as observations providing the upper bounds from the
confidence interval.
YmaxR: numeric vector giving, at each value in time, the index number of the variable
whose correlation is calculated against a linear combination of the rest. By
default, wlmc chooses at each weach value in time the variable maximizing the
multiple correlation.
Author(s)
Javier Fernández-Macho, Dpt. of Econometrics and Statistics, & Instituto de Economía Pública,
University of the Basque Country, Agirre Lehendakari etorb. 83, E48015 BILBAO, Spain. (email:
javier.fernandezmacho@ehu.eus).
References
Fernández-Macho, J., 2018. Time-localized wavelet multiple regression and correlation, Physica
A: Statistical Mechanics, vol. 490, p. 1226–1238. <DOI:10.1016/j.physa.2017.11.050>
Examples
library(wavemulcor)
options(warn = -1)
wf <- "d4"
M <- N/2^3 #sharper with N/2^4
window <- "gaussian"
4 wave.local.multiple.correlation
J <- trunc(log2(N))-3
# ################################################################################################
ts.plot(cbind(xrand1,xrand2),col=c("red","blue"),xlab="time")
xx <- data.frame(xrand1,xrand2)
# ################################################################################################
# ################################################################################################
old.par <- par()
matplot(1:N,cbind(val,lo,up),
main=title, #sub=sub,
xlab=xlab, ylab=ylab, type="l", lty=1, col= c(1,2,2), cex.axis=0.75)
abline(h=0) ##Add Straight horiz and vert Lines to a Plot
wave.local.multiple.correlation
Wavelet routine for local multiple correlation
wave.local.multiple.correlation 5
Description
Produces an estimate of the multiscale local multiple correlation (as defined below) along with
approximate confidence intervals.
Usage
wave.local.multiple.correlation(xx, M, window="gauss", p = .975, ymaxr=NULL)
Arguments
xx A list of n (multiscaled) time series, usually the outcomes of dwt or modwt, i.e.
xx <- list(v1.modwt.bw, v2.modwt.bw, v3.modwt.bw)
M length of the weight function or rolling window.
window type of weight function or rolling window. Six types are allowed, namely the
uniform window, Cleveland or tricube window, Epanechnikov or parabolic win-
dow, Bartlett or triangular window, Wendland window and the gaussian window.
The letter case and length of the argument are not relevant as long as at least the
first four characters are entered.
p one minus the two-sided p-value for the confidence interval, i.e. the cdf value.
ymaxr index number of the variable whose correlation is calculated against a linear
combination of the rest, otherwise at each wavelet level wlmc chooses the one
maximizing the multiple correlation.
Details
The routine calculates one single set of wavelet multiple correlations out of n variables that can be
plotted in in either single heatmap or J line graphs (the former is usually the best graphic option
but the latter is useful if confidence intervals are explicitly needed), as an alternative to trying to
make sense out of n(n − 1)/2.[JxT ] sets of local wavelet correlations. The code is based on the
calculation, at each wavelet scale, of the square root of the coefficient of determination in that linear
combination of locally weighted wavelet coefficients for which such coefficient of determination
is a maximum. The code provided here is based on the wave.multiple.correlation routine in this
package which in turn is based on the wave.correlation routine in Brandon Whitcher’s waveslim R
package Version: 1.6.4, which in turn is based on wavelet methodology developed in Percival and
Walden (2000); Gençay, Selçuk and Whitcher (2001) and others.
Value
List of four elements:
val: matrix with as many rows as observations and as many columns as levels in
the wavelet transform object providing the point estimates for the wavelet local
multiple correlation.
lo: matrix with as many rows as observations and as many columns as levels in
the wavelet transform object providing the lower bounds from the confidence
interval.
6 wave.local.multiple.correlation
up: matrix with as many rows as observations and as many columns as levels in
the wavelet transform object providing the upper bounds from the confidence
interval.
YmaxR: numeric vector giving, at each wavelet level, the index number of the variable
whose correlation is calculated against a linear combination of the rest. By
default, wlmc chooses at each wavelet level the variable maximizing the multiple
correlation.
Note
Needs waveslim package to calculate dwt or modwt coefficients as inputs to the routine (also for
data in the example).
Author(s)
Javier Fernández-Macho, Dpt. of Econometrics and Statistics, & Instituto de Economía Pública,
University of the Basque Country, Agirre Lehendakari etorb. 83, E48015 BILBAO, Spain. (email:
javier.fernandezmacho@ehu.eus).
References
Fernández-Macho, J., 2018. Time-localized wavelet multiple regression and correlation, Physica
A: Statistical Mechanics, vol. 490, p. 1226–1238. <DOI:10.1016/j.physa.2017.11.050>
Examples
library(wavemulcor)
library(plot3D)
options(warn = -1)
data(xrand)
N <- length(xrand1)
b <- trunc(N/3)
t1 <- 1:b
t2 <- (b+1):(2*b)
t3 <- (2*b+1):N
wf <- "d4"
M <- N/2^3 #sharper with N/2^4
window <- "gaussian"
J <- trunc(log2(N))-3
# ################################################################################################
ts.plot(cbind(xrand1,xrand2),col=c("red","blue"),xlab="time")
xx <- list(xrand1.modwt.bw,xrand2.modwt.bw)
# ################################################################################################
# ################################################################################################
old.par <- par()
################################################################################################
##Producing line plots with confidence intervals
wave.multiple.correlation
Wavelet routine for multiple correlation
Description
Produces an estimate of the multiscale multiple correlation (as defined below) along with approxi-
mate confidence intervals.
Usage
wave.multiple.correlation(xx, N, p = 0.975, ymaxr=NULL)
Arguments
xx A list of n (multiscaled) time series, usually the outcomes of dwt or modwt, i.e.
xx <- list(v1.modwt.bw, v2.modwt.bw, v3.modwt.bw)
N length of the time series
p one minus the two-sided p-value for the confidence interval, i.e. the cdf value.
ymaxr index number of the variable whose correlation is calculated against a linear
combination of the rest, otherwise at each wavelet level wmc chooses the one
maximizing the multiple correlation.
Details
The routine calculates one single set of wavelet multiple correlations out of n variables that can
be plotted in a single graph, as an alternative to trying to make sense out of n(n − 1)/2 sets of
wavelet correlations. The code is based on the calculation, at each wavelet scale, of the square root
of the coefficient of determination in the linear combination of variables for which such coefficient
of determination is a maximum. The code provided here is based on the wave.correlation routine
in Brandon Whitcher’s waveslim R package Version: 1.6.4, which in turn is based on wavelet
methodology developed in Percival and Walden (2000); Gençay, Selçuk and Whitcher (2001) and
others.
wave.multiple.correlation 9
Value
List of two elements:
xy.mulcor: matrix with as many rows as levels in the wavelet transform object. The first column
provides the point estimate for the wavelet multiple correlation, followed by the lower and upper
bounds from the confidence interval.
YmaxR: numeric vector giving, at each wavelet level, the index number of the variable whose corre-
lation is calculated against a linear combination of the rest. By default, wmc chooses at each wavelet
level the variable maximizing the multiple correlation.
Note
Needs waveslim package to calculate dwt or modwt coefficients as inputs to the routine (also for
data in the example).
Author(s)
Javier Fernández-Macho, Dpt. of Econometrics and Statistics, & Instituto de Economía Pública,
University of the Basque Country, Agirre Lehendakari etorb. 83, E48015 BILBAO, Spain. (email:
javier.fernandezmacho@ehu.eus).
References
Fernández-Macho, J., 2012. Wavelet multiple correlation and cross-correlation: A multiscale anal-
ysis of Eurozone stock markets. Physica A: Statistical Mechanics and its Applications 391, 1097-
1104. <DOI:10.1016/j.physa.2011.11.002>
Examples
## Based on data from Figure 7.8 in Gencay, Selcuk and Whitcher (2001)
## plus one random series.
library(wavemulcor)
data(exchange)
returns <- diff(log(as.matrix(exchange)))
returns <- ts(returns, start=1970, freq=12)
wf <- "d4"
J <- 6
##Producing plot
wave.multiple.cross.correlation
Wavelet routine for multiple cross-correlation
Description
Usage
Arguments
xx A list of n (multiscaled) time series, usually the outcomes of dwt or modwt, i.e.
xx <- list(v1.modwt.bw, v2.modwt.bw, v3.modwt.bw)
lag.max maximum lag. If not set, it defaults to half the square root of the length of the
original series.
ymaxr index number of the variable whose correlation is calculated against a linear
combination of the rest, otherwise at each wavelet level wmc chooses the one
maximizing the multiple correlation.
Details
The routine calculates one single set of wavelet multiple cross-correlations out of n variables that
can be plotted as one single set of graphs (one per wavelet level), as an alternative to trying to make
sense out of n(n−1)/2.J sets of wavelet cross-correlations. The code is based on the calculation, at
each wavelet scale, of the square root of the coefficient of determination in a linear combination of
variables that includes a lagged variable for which such coefficient of determination is a maximum.
wave.multiple.cross.correlation 11
Value
List of two elements:
xy.mulcor: matrix with as many rows as levels in the wavelet transform object. The columns pro-
vide the point estimates for the wavelet multiple cross-correlations at different lags.
YmaxR: numeric vector giving, at each wavelet level, the index number of the variable whose cor-
relation is calculated against a linear combination of the rest. By default, wmcc chooses at each
wavelet level the variable maximizing the multiple correlation.
Note
Needs waveslim package to calculate dwt or modwt coefficients as inputs to the routine (also for
data in the example).
Author(s)
Javier Fernández-Macho, Dpt. of Econometrics and Statistics, & Instituto de Economía Pública,
University of the Basque Country, Agirre Lehendakari etorb. 83, E48015 BILBAO, Spain. (email:
javier.fernandezmacho@ehu.eus).
References
Fernández-Macho, J., 2012. Wavelet multiple correlation and cross-correlation: A multiscale anal-
ysis of Eurozone stock markets. Physica A: Statistical Mechanics and its Applications 391, 1097-
1104. <DOI:10.1016/j.physa.2011.11.002>
Examples
## Based on data from Figure 7.9 in Gencay, Selcuk and Whitcher (2001)
## plus one random series.
library(wavemulcor)
data(exchange)
returns <- diff(log(exchange))
returns <- ts(returns, start=1970, freq=12)
wf <- "d4"
J <- 6
lmax <- 36
n <- dim(returns)[1]
Description
Usage
data("xrand")
Format
Details
xrand1[t] and xrand2[t] are highly correlated at low frequencies (long timescales) but uncorrelated
at high frequencies (short timescales). However, during a period of time spanning the second third
of the sample (T /3 < t < 2T /3) that behavior is reversed so that data become highly correlated at
short timescales but uncorrelated at low frequencies.
References
Fernández-Macho, J., 2017. Time-localized wavelet multiple regression and correlation, (mimeo).
Examples
data(xrand)
## maybe str(xrand) ; plot(xrand) ...
Description
Simulated data showing correlation structural breaks in Figure 4 of Fernández-Macho (2017).
Usage
data("xrand")
Format
A data frame with 512 observations on 1 variables.
Details
xrand1[t] and xrand2[t] are highly correlated at low frequencies (long timescales) but uncorrelated
at high frequencies (short timescales). However, during a period of time spanning the second third
of the sample (T /3 < t < 2T /3) that behavior is reversed so that data become highly correlated at
short timescales but uncorrelated at low frequencies.
References
Fernández-Macho, J., 2017. Time-localized wavelet multiple regression and correlation, (mimeo).
Examples
data(xrand)
## maybe str(xrand) ; plot(xrand) ...
14 xrand2
Description
Simulated data showing correlation structural breaks in Figure 4 of Fernández-Macho (2017).
Usage
data("xrand")
Format
A data frame with 512 observations on 1 variables.
xrand2 a numeric vector
Details
xrand1[t] and xrand2[t] are highly correlated at low frequencies (long timescales) but uncorrelated
at high frequencies (short timescales). However, during a period of time spanning the second third
of the sample (T /3 < t < 2T /3) that behavior is reversed so that data become highly correlated at
short timescales but uncorrelated at low frequencies.
References
Fernández-Macho, J., 2017. Time-localized wavelet multiple regression and correlation, (mimeo).
Examples
data(xrand)
## maybe str(xrand) ; plot(xrand) ...
Index
lmc (local.multiple.correlation), 2
local.multiple.correlation, 2
wave.local.multiple.correlation, 4
15