dCovTS : Distance Covariance / Correlation for Time Series by

The distance covariance function is a new measure of dependence between random vectors. We drop the assumption of iid data to introduce distance covariance for time series. The R package dCovTS provides functions that compute and plot distance covariance and correlation functions for both univariate and multivariate time series. Additionally it includes functions for testing serial independence based on distance covariance. This paper describes the theoretical background of distance covariance methodology in time series and discusses in detail the implementation of these methods with the R package dCovTS. Introduction There has been a considerable recent interest in measuring dependence by employing the concept of the distance covariance function . Székely et al. (2007) initially introduced the distance covariance as a new measure of dependence defined as the weighted L2-norm between the joint characteristic function of two random vectors of arbitrary, but not necessarily of equal dimensions, and their marginal characteristic functions. However, the idea of using distance covariance for detecting independence can be also found in some early work by Feuerverger (1993). He considered measures of this form, with the main differences being the restriction to the univariate case and the choice of the weight function. Since Székely et al.’s (2007) work, there has been a wide range of studies extending the distance covariance definition and methodology in various topics; see Gretton et al. (2009) and Josse and Holmes (2014) and the references therein for a nice review. Székely et al.’s (2007) distance covariance methodology is based on the assumption that the underlying data are iid. However, this assumption is often violated in many practical problems. Remillard (2009) proposed to extend the distance covariance methodology to a time series context in order to measure serial dependence. There have been few works on how to develop a distance covariance methodology in the context of time series (Zhou, 2012; Dueck et al., 2014; Davis et al., 2016). Motivated by the work of Székely et al. (2007), Zhou (2012) recently defined the so-called autodistance covariance function (ADCV) and its rescaled version, the so-called auto-distance correlation function (ADCF), for a strictly stationary multivariate time series. Compared to the classical Pearson autocorrelation function (ACF) which measures the strength of linear dependencies and can be equal to zero even when the variables are related, ADCF vanishes only in the case where the observations are independent. However, Zhou (2012) studied the asymptotic behavior of ADCV at a fixed lag order. Fokianos and Pitsillou (2016a) relaxed this assumption and constructed a univariate test of independence by considering an increasing number of lags following Hong’s (1999) generalized spectral domain methodology. Although the proposed methodology is for univariate processes, it can be extended for multivariate processes. Zhou (2012) developed a distance covariance methodology for multivariate time series, but he did not explore the interrelationships between the various time series components. Fokianos and Pitsillou (2016b) made this possible by defining the matrix version of pairwise auto-distance covariance and correlation functions. In particular, they construct multivariate tests of independence based on these new measures in order to identify whether there is some inherent nonlinear interdependence between the component series. The energy (Rizzo and Szekely, 2014) package for R is a package that involves a wide range of functions for the existing distance covariance methodology. However, there is no package for the aforementioned distance covariance methodology in time series. Thus, we aim at filling this gap by publishing an R-package named dCovTS. In this first version of the package, we provide functions that compute and plot ADCV and ADCF using the functions dcov() and dcor() respectively from energy package. The new testing methodology proposed by Fokianos and Pitsillou (2016a,b) is also included in the package. The structure of the paper is as follows. In the first two sections we introduce the theoretical background of distance covariance function for both univariate and multivariate time series respectively. In the next section, we briefly state the main results about the asymptotic properties of distance covariance function. The proposed testing methodology for both univariate and multivariate time series are also described. Empirical p-values of the tests and empirical critical values for the distance correlation plots are computed via the wild bootstrap methodology (Dehling and Mikosch, 1994; Shao, 2010; Leucht and Neumann, 2013b) which is explained in the corresponding section. The implementation The R Journal Vol. 8/2, December 2016 ISSN 2073-4859 CONTRIBUTED RESEARCH ARTICLES 325 section demonstrates the usage of the package with two real data examples. Lastly, we give some concluding remarks and some further points for future extensions of the dCovTS package. Distance covariance function Denote a univariate strictly stationary time series by {Xt, t ∈ Z}. Motivated by Székely et al. (2007) and Zhou (2012), we define the distance covariance function as a function of the joint and marginal characteristic functions of the pair (Xt, Xt+j). Denote by φj(u, v) the joint characteristic function of Xt and Xt+j; that is φj(u, v) = E [ exp ( i ( uXt + vXt+j ))] , j = 0,±1,±2, . . . , and the marginal characteristic functions of Xt and Xt+j as φ(u) := φj(u, 0) and φ(v) := φj(0, v) respectively, where (u, v) ∈ R2, and i2 = −1. For a strictly stationary α-mixing univariate time series, Hong (1999) defined a new measure of dependence between the joint characteristic function of Xt and its lagged observation Xt+j and the product of their marginals, namely σj(u, v) = φj(u, v)− φ(u)φ(v), j = 0,±1,±2, . . . , (1) where (u, v) ∈ R2. Considering the property that the joint characteristic function factorizes under independence of Xt and Xt+j, σj(u, v) equals 0 if and only if Xt and Xt+j are independent. Thus, compared to the classical autocorrelation function (ACF), σj(·, ·) can capture all pairwise dependencies including those with zero autocorrelation. The auto-distance covariance function (ADCV), VX(j), between Xt and Xt+j is then defined as the square root of V2 X(j) = ∫ R2 ∣∣∣σj(u, v)∣∣∣2 dW(u, v), j = 0,±1,±2, . . . (2) whereW(·, ·) is a positive weight function for which the above integral exists. Although Hong (1999) suggests the use of an arbitrary integrable weight function, W(·, ·), we propose the use of a non-integrable weight function, i.e. W(u, v) =W0(u)W0(v) = 1 π |u| 1 π |v| , (u, v) ∈ R2 (3) which avoids missing any potential dependence among observations (Székely et al., 2007, p. 2771). Rescaling (2), one can define the auto-distance correlation function (ADCF) as the positive square root of RX(j) = V2 X(j) V2 X(0) , j = 0,±1,±2, . . . (4) for V2 X(0) 6= 0 and zero otherwise. Székely et al. (2007) showed that by applying a non-integrable weight function, like (3), ADCF is scale invariant and is not zero under dependence. The empirical ADCV, V̂X(·), is the non-negative square root of V̂2 X(j) = 1 (n− j)2 n ∑ r,l=1+j Arl Brl , 0 ≤ j ≤ (n− 1) (5) and V̂2 X(−j) = V̂2 X(j), for −(n − 1) ≤ j < 0, where A = Arl and B = Brl are Euclidean distance matrices given by Arl = arl − ār. − ā.l + ā.., with arl = |Xr − Xl |, ār. = ( ∑l=1+j arl ) /(n− j), ā.l = ( ∑n r=1+j arl ) /(n− j), ā.. = ( ∑n r,l=1+j arl ) /(n− j)2. Brl is defined analogously in terms of brl = |Yr −Yl |, where Yt ≡ Xt+j. Székely and Rizzo (2014) proposed an unbiased version of the sample distance covariance. In the context of time series data this is given by Ṽ2 X(j) = 1 (n− j)(n− j− 3) ∑ r 6=l Ãrl B̃rl , (6) for n > 3, where Ãrl is the (r, l) element of the so-called U -centered matrix Ã, defined by The R Journal Vol. 8/2, December 2016 ISSN 2073-4859 CONTRIBUTED RESEARCH ARTICLES 326 Ãrl =  arl − 1 n− j− 2 n ∑ t=1+j art − 1 n− j− 2 n ∑ s=1+j asl + 1 (n− j− 1)(n− j− 2) n ∑ t,s=1+j ats, r 6= l; 0, r = l. The empirical ADCF, R̂X(j) (or its unbiased version, R̃X(j)), can be obtained by replacing (5) (or (6)) into (4). The functions ADCV() and ADCF() in dCovTS return the empirical quantities V̂X(·) and R̂X(·) respectively. Using the same functions with argument unbiased=TRUE, the results correspond to the unbiased sqaured quantities Ṽ2 X(·) and R̃X(·). Note that the default option has been set to unbiased=FALSE (corresponding to (5)). Distance covariance matrix We denote by {Xt : t = 0,±1,±2, . . . } a d-dimensional time series process, with components {Xt;i} i=1. The characteristic functions can be defined in analogous way as in the univariate case. In particular, the joint characteristic function of Xt;r and Xt+j;m is given by φ (r,m) j (u, v) = E [ exp ( i ( uXt;r + vXt+j;m ))] , j = 0,±1,±2, . . . and the marginal characteristic functions of Xt;r and Xt+j;m by φ(r)(u) := φ (r,m) j (u, 0) and φ (m)(v) := φ (r,m) j (0, v) respectively, with (u, v) ∈ R 2, r, m = 1, . . . d and i2 = −1. The pairwise ADCV between Xt;r and Xt+j;m is denoted by Vrm(j) and it is defined as the non-negative square root of V2 rm(j) = ∫ R2 ∣∣∣σ(r,m) j (u, v)∣∣∣2W(u, v)dudv, j = 0,±1,±2, . . . whereW(·, ·) is given by (3) and σ j (u, v) is similarly defined as in the univariate case, namely σ (r,m) j (u, v) = φ (r,m) j (u, v)− φ (r)(u)φ(m)(v). Clearly, V2 rm(j) ≥ 0, ∀ j and Xt;r and Xt+j;m are independent if and only if V2 rm(j) = 0. The ADCV matrix, V(j), is then defined by V(j) = [ Vrm(j) ]d r,m=1 , j = 0,±1,±2, . . . (7) The pairwise ADCF between Xt;r and Xt+j;m, Rrm(j), is a coefficient that lies in the interval [0, 1] and also measures dependence and is defined as the positive square root of Rrm(j) = V2 rm(j) √ V2 rr(0) √ V2 mm(0) , (8) for Vrr(0)Vmm(0) 6= 0 and zero otherwise. The ADCF matrix of Xt, is then defined as R(j) = [ Rrm(j) ]d


Introduction
There has been a considerable recent interest in measuring dependence by employing the concept of the distance covariance function.Székely et al. (2007) initially introduced the distance covariance as a new measure of dependence defined as the weighted L 2 -norm between the joint characteristic function of two random vectors of arbitrary, but not necessarily of equal dimensions, and their marginal characteristic functions.However, the idea of using distance covariance for detecting independence can be also found in some early work by Feuerverger (1993).He considered measures of this form, with the main differences being the restriction to the univariate case and the choice of the weight function.Since Székely et al.'s (2007) work, there has been a wide range of studies extending the distance covariance definition and methodology in various topics; see Gretton et al. (2009) and Josse and Holmes (2014) and the references therein for a nice review.Székely et al.'s (2007) distance covariance methodology is based on the assumption that the underlying data are iid.However, this assumption is often violated in many practical problems.Remillard (2009) proposed to extend the distance covariance methodology to a time series context in order to measure serial dependence.There have been few works on how to develop a distance covariance methodology in the context of time series (Zhou, 2012;Dueck et al., 2014;Davis et al., 2016).Motivated by the work of Székely et al. (2007), Zhou (2012) recently defined the so-called autodistance covariance function (ADCV) -and its rescaled version, the so-called auto-distance correlation function (ADCF), for a strictly stationary multivariate time series.Compared to the classical Pearson autocorrelation function (ACF) which measures the strength of linear dependencies and can be equal to zero even when the variables are related, ADCF vanishes only in the case where the observations are independent.However, Zhou (2012) studied the asymptotic behavior of ADCV at a fixed lag order.Fokianos and Pitsillou (2016a) relaxed this assumption and constructed a univariate test of independence by considering an increasing number of lags following Hong's (1999) generalized spectral domain methodology.Although the proposed methodology is for univariate processes, it can be extended for multivariate processes.Zhou (2012) developed a distance covariance methodology for multivariate time series, but he did not explore the interrelationships between the various time series components.Fokianos and Pitsillou (2016b) made this possible by defining the matrix version of pairwise auto-distance covariance and correlation functions.In particular, they construct multivariate tests of independence based on these new measures in order to identify whether there is some inherent nonlinear interdependence between the component series.
The energy (Rizzo and Szekely, 2014) package for R is a package that involves a wide range of functions for the existing distance covariance methodology.However, there is no package for the aforementioned distance covariance methodology in time series.Thus, we aim at filling this gap by publishing an R-package named dCovTS.In this first version of the package, we provide functions that compute and plot ADCV and ADCF using the functions dcov() and dcor() respectively from energy package.The new testing methodology proposed by Fokianos and Pitsillou (2016a,b) is also included in the package.
The structure of the paper is as follows.In the first two sections we introduce the theoretical background of distance covariance function for both univariate and multivariate time series respectively.In the next section, we briefly state the main results about the asymptotic properties of distance covariance function.The proposed testing methodology for both univariate and multivariate time series are also described.Empirical p-values of the tests and empirical critical values for the distance correlation plots are computed via the wild bootstrap methodology (Dehling and Mikosch, 1994;Shao, 2010;Leucht and Neumann, 2013b) which is explained in the corresponding section.The implementation The R Journal Vol.8/2, December 2016 ISSN 2073-4859 section demonstrates the usage of the package with two real data examples.Lastly, we give some concluding remarks and some further points for future extensions of the dCovTS package.

Distance covariance function
Denote a univariate strictly stationary time series by {X t , t ∈ Z}.Motivated by Székely et al. (2007) and Zhou (2012), we define the distance covariance function as a function of the joint and marginal characteristic functions of the pair (X t , X t+j ).Denote by φ j (u, v) the joint characteristic function of X t and X t+j ; that is and the marginal characteristic functions of X t and X t+j as φ(u) := φ j (u, 0) and φ(v) := φ j (0, v) respectively, where (u, v) ∈ R 2 , and i 2 = −1.For a strictly stationary α-mixing univariate time series, Hong (1999) defined a new measure of dependence between the joint characteristic function of X t and its lagged observation X t+j and the product of their marginals, namely where (u, v) ∈ R 2 .Considering the property that the joint characteristic function factorizes under independence of X t and X t+j , σ j (u, v) equals 0 if and only if X t and X t+j are independent.Thus, compared to the classical autocorrelation function (ACF), σ j (•, •) can capture all pairwise dependencies including those with zero autocorrelation.The auto-distance covariance function (ADCV), V X (j), between X t and X t+j is then defined as the square root of where W (•, •) is a positive weight function for which the above integral exists.
Although Hong (1999) suggests the use of an arbitrary integrable weight function, W (•, •), we propose the use of a non-integrable weight function, i.e.
The empirical ADCV, V X (•), is the non-negative square root of and V 2 X (−j) = V 2 X (j), for −(n − 1) ≤ j < 0, where A = A rl and B = B rl are Euclidean distance matrices given by A rl = a rl − ār.− ā.l + ā.. , Székely and Rizzo (2014) proposed an unbiased version of the sample distance covariance.In the context of time series data this is given by for n > 3, where A rl is the (r, l) element of the so-called U -centered matrix A, defined by The R Journal Vol.8/2, December 2016 ISSN 2073-4859 The empirical ADCF, R X (j) (or its unbiased version, R X (j)), can be obtained by replacing (5) (or (6)) into (4).The functions ADCV() and ADCF() in dCovTS return the empirical quantities V X (•) and R X (•) respectively.Using the same functions with argument unbiased=TRUE, the results correspond to the unbiased sqaured quantities V 2 X (•) and R 2 X (•).Note that the default option has been set to unbiased=FALSE (corresponding to (5)).

Distance covariance matrix
We denote by {X t : t = 0, ±1, ±2, . . .} a d-dimensional time series process, with components {X t;i } d i=1 .The characteristic functions can be defined in analogous way as in the univariate case.In particular, the joint characteristic function of X t;r and X t+j;m is given by , j = 0, ±1, ±2, . . .and the marginal characteristic functions of X t;r and X t+j;m by φ (r) (u The pairwise ADCV between X t;r and X t+j;m is denoted by V rm (j) and it is defined as the non-negative square root of Clearly, V 2 rm (j) ≥ 0, ∀ j and X t;r and X t+j;m are independent if and only if V 2 rm (j) = 0.The ADCV matrix, V(j), is then defined by The pairwise ADCF between X t;r and X t+j;m , R rm (j), is a coefficient that lies in the interval [0, 1] and also measures dependence and is defined as the positive square root of for V rr (0)V mm (0) = 0 and zero otherwise.The ADCF matrix of X t , is then defined as , j = 0, ±1, ±2, . . .
V rm (j) measures the dependence of X t;r on X t+j;m .In general, V rm (j) = V mr (j) for r = m, since they measure different dependence structure between the series {X t;r } and {X t;m } for all r, m = 1, 2, . . ., d.Thus, V(j) and R(j) are non-symmetric matrices.Moreover, because of the assumed stationarity and relation Cov(x, y) = Cov(y, x), V(j) = V (−j) and consequently R(j) = R (−j).More properties of these new defined functions can be found in Fokianos and Pitsillou (2016b).
Estimation of V 2 rm (•) can be dealt in a similar way as in the univariate case.In particular, let first Y t;m ≡ X t+j;m .Based on the sample {(X t;r , Y t;m ) : t = 1 + j, . . ., n}, we define the Euclidean distance matrices by (a Analogously to ( 6), an unbiased estimator of V 2 rm (•) is given by where A r ts are computed appropriately.The sample ADCV matrix, V(•), is then obtained by replacing its elements by the positive square root of ( 9) and can be calculated from dCovTS using the mADCV() function.The estimator based on (10), V(•), is obtained from dCovTS using the argument unbiased = TRUE.The package also gives the sample ADCF matrix R(•) (function mADCF()) which is obtained after replacing (9) (or R X (j) which is based on (6)) into ( 8).The distance correlation plots for both univariate and multivariate time series are obtained by the ADCFplot() and mADCFplot() functions respectively, where the shown critical values (blue dotted horizontal line) are computed by employing bootstrap methodology described in the appropriate section.Recall that these are computed by using the biased definition of distance covariance and correlation.

Consistency and asymptotic distribution of distance covariance
Consider first the univariate case.For a strictly stationary and α-mixing process X t , with E |X t | < ∞, then for all j = 0, ±1, ±2, . . .
V 2 X (j) → V 2 X (j) almost surely, as n → ∞.A detailed proof of this result can be found in Fokianos and Pitsillou (2016a).Under mild conditions, Zhou (2012) obtained the weak consistency of V 2 X (•) and its asymptotic distribution at a fixed lag, but under alternative mixing conditions.
almost surely as n → ∞.Under pairwise independence, the empirical pairwise ADCV is a degenerate V-statistic of order two with a measurable kernel function that is symmetric, continuous and positive semidefinite Then in distribution, as n → ∞, where {Z k } is an iid sequence of N(0, 1) random variables, and (λ k ) is a sequence of nonzero eigenvalues.A similar result showing the limiting distribution of V rm (•) can be obtained by replacing V X (•) by V rm (•) in (11).

Testing for pairwise dependence in univariate time series
As shown in the previous section, the asymptotic distribution of distance covariance is derived at a fixed lag, for both univariate and multivariate time series.Fokianos and Pitsillou (2016a,b) constructed the asymptotic behavior of distance covariance considering an increasing number of lags by employing Hong's (1999) generalized spectral domain methodology.Hong (1999) highlighted that standard spectral density approaches become inappropriate for non-Gaussian and nonlinear processes with zero autocorrelation.Considering a univariate strictly stationary α-mixing process, he proposed The R Journal Vol.8/2, December 2016 ISSN 2073-4859 the generalized spectral density, which is the Fourier transform of σ j (u, v) defined in (1), given by Under the null hypothesis of independence, the corresponding null density is given by Any deviation of f from f 0 is a strong evidence of pairwise dependence.Thus, Hong (1999) compares the Parzen's (1957) kernel-type estimators f (ω, u, v) and f0 (ω, u, v) via an L 2 -norm resulting in a test statistic of the form where W (•, •) : R 2 → R is an arbitrary nondecreasing function with bounded total variation, p is a bandwidth of the form p = cn λ for c > 0 λ ∈ (0, 1) and k(•) is a Lipschitz-continuous kernel function satisfying the following assumption: ] is symmetric and is continuous at 0 and at all but a finite number of points, with The function kernelFun() in dCovTS computes a number of such kernel functions including the truncated (default option), Bartlett, Daniell, QS and Parzen kernels.Fokianos and Pitsillou (2016a) proposed a portmanteau type statistic based on ADCV Under the null hypothesis that the data are iid and some further assumptions about the kernel function k(•), the standardized version of T n follows a N(0, 1) asymptotically, and it is consistent.The authors also considered a similar test statistic based on ADCF The function UnivTest from dCovTS package performs univariate tests of independence based on (13) and its rescaled version (14), using the arguments testType = "covariance" and testType = "correlation" respectively.

Testing for pairwise dependence in multivariate time series
Following a similar methodology described in the previous section, Fokianos and Pitsillou (2016b) suggested a test statistic suitable for testing pairwise independence in a multivariate time series framework.The proposed test statistic is based on the ADCV matrix (7), and it is given by where k(•) is a univariate kernel function satisfying Assumption 1, p is a bandwidth as described before.Moreover, V * (•) denotes the complex conjugate matrix of V(•) and tr(A) denotes the trace of the matrix A. The authors formed the statistic (15) in terms of the ADCF matrix as follows where D = diag{V rr (0), r = 1, 2, . . ., d}.Under the null hypothesis of independence and some further assumptions about the kernel function k(•), the standardized version of the test statistics T n and T n given in ( 15) and ( 16) were proved to follow N(0, 1) asymptotically and they are consistent.

Bootstrap methodology
To examine the asymptotic behavior of the proposed test statistics, a resampling method is proposed.First, recall that all test statistics T n , T n and T n of equations ( 13), ( 15) and ( 16) respectively, are functions of degenerate Vstatistics of order two.Dehling and Mikosch (1994) proposed wild bootstrap techniques to approximate the distribution of degenerate U-statistics for the case of iid data.Recently, Leucht and Neumann (2013a,b) suggested the use of a new variant of dependent wild bootstrap (Shao, 2010) to approximate the limit distribution of degenerate Uand V-statistics for dependent data.The method relies on generating auxiliary random variables (W * tn ) n−j t=1 .Shao (2010) highlighted that the methodology of wild bootstrap for time series extends that of Wu (1986) by allowing the auxiliary random variables W * tn to be dependent.In particular, Leucht and Neumann (2013b) proposed to generate the sequence W * tn by a first order autoregressive model.In the case of independent data, Dehling and Mikosch (1994) studied the wild bootstrap methodology by employing independent auxiliary variables W * tn .Because our focus is on testing independence we implement the calculation of the test statistics by using W * tn iid standard normal random variables.Thus, the empirical p-values of the tests are derived based on this methodology.
We also suggest the use of independent wild bootstrap for obtaining simultaneous 95% empirical critical values for the distance correlation plots.In the case of a univariate time series, we additionally propose the subsampling approach suggested by Zhou (2012, Section 5.1) for computing the pairwise 95% critical values (argument method = "Subsampling").The choice of the subsampling block size is based on the minimum volatility method proposed by Politis et al. (1999, Section 9.4.2).In addition, the package provides the ordinary independent bootstrap methodology to derive empirical p-values of the tests and simultaneous 95% critical values for the ADCF plots (argument method = "Independent Bootstrap").The default bootstrap method provided to the user is the independent wild bootstrap technique.
The computation of the bootstrap replications, and thus the empirical p-values and the critical values, can be distributed to multiple cores simultaneously (argument parallel = TRUE).To do this, the doParallel (Analytics and Weston, 2015) package needs to be installed first, in order to register a computing cluster.

Implementation of dCovTS package
The current version of dCovTS package (version number 1.1) is available from CRAN and can be downloaded via https://cran.r-project.org/web/packages/dCovTS/. The aim of the dCovTS package is to provide a set of functions that compute and plot distance covariance and correlation functions in both univariate and multivariate time series.As we mentioned, the package supports both versions of biased and unbiased estimators of distance covariance and correlation functions.Moreover, it offers functions that perform univariate and multivariate tests of independence based on distance covariance function using the biased estimator (corresponding to (5) and ( 9)).All these functions are provided in Table 1.Apart from these functions, the package also provides two real datasets listed in Table 2.A more detailed description of the functions and datasets can be found in the help files.We apply dCovTS to two real data examples.

Regression with autocorrelated errors
We first consider the pollution, temperature and mortality data measured daily in Los Angeles County over the 10 year period 1970-1979(Shumway et al., 1988)).The data are available in our package by the argument MortTempPart and contain 508 observations and 3 variables representing the mortality ("cmort"), temperature ("tempr") and pollutant particulates ("part") data.Following the analysis of Shumway and Stoffer (2011), the possible effects of temperature (T t ) and pollutant particulates (P t ) on daily cardiovascular mortality (M t ) are examined via regression.In particular, once the temperature is adjusted for its mean (T .= 74.3),we fit the following regression model using the function lm() where the standard errors of the estimators are given in parentheses.Figure 1 provides the sample autocorrelation (ACF), partial correlation (PACF) and ADCF plots of the residuals of model ( 17).The plots shown in Figure 1 suggest an AR(2) process for the residuals.The new fit is where the standard errors of the estimators are given in parentheses.The above model fit was derived by using the arima() function of R. The correlation plots for the residuals from the new model ( 18) are shown in Figure 2 indicating that there is no serial dependence.The calls for both model fits and their diagnostic plots are given below.ADCF plots (lower plots of Figures 1 and 2) are constructed using both resampling schemes explained in the previous section: independent wild bootstrap (with b = 499 replications) and subsampling.

Bivariate financial time series
We now analyze the monthly log returns of the stocks of International Business Machines (IBM) and the S&P 500 composite index starting from 30 September 1953 to 30 December 2011 for 700 observations.A larger dataset is available in our package by the object ibmSp500 starting from January 1926 for 1032 observations.It is actually a combination of two smaller datasets: the first one was first reported by Tsay (2010) and the second one was first reported by Tsay (2014).ACF and ADCF plots of the original series are provided in Figure 3, whereas Figure 4 shows the ACF and ADCF plots of the squared series.
The R commands for constructing these plots are as follows: data(ibmSp500) new_data <-tail(ibmSp500[,2:3], 700) series <-log(new_data + 1) t=scale(lseries, center = TRUE, scale = FALSE) t2 <-at^2 olnames(at) <-c("IBM", "SP") olnames(at2) <-c("IBM_sq", "SP_sq") cf(at, lag.max = 18) cf(at2, lag.max = 18) ADCFplot(at, MaxLag = 18, ylim = c(0, 0.2)) ADCFplot(at2, MaxLag = 18, ylim = c(0, 0.2)) The ACF plots of the original series (upper panel of Figure 3) suggest no serial correlation among observations, while the ACF plots of the squared series (upper panel of Figure 4) imply strong dependence.This confirms the conditional heteroscedasticity in the monthly log returns.However, the ADCF plots for both original and squared series (lower panels of Figures 3 and 4) suggest dependence.Indeed, choosing p = 3n λ for λ = 0.1, 0.2 and 0.3, that is p = 6, 12 and 22, and employing Bartlett kernel, T n gives low p-values (0.022, 0.014 and 0.020 respectively).The calls for these three multivariate tests of independence can be found below (they take about 2, 3 and 6 minutes respectively for b = 499 bootstrap replications on a standard laptop with Intel Core i5 system and CPU 2.30 GHz): To compare the performance of the proposed test statistic T n , we consider the multivariate Ljung-Box statistic (Hosking, 1980) defined by: mLB = n 2 p ∑ j=1 (n − j) −1 tr{ Γ (j) Γ −1 (0) Γ(j) Γ −1 (0)} where Γ(•) is the ordinary covariance matrix.In contrast to the M n 's results, mLB gives large p-values (0.218, 0.731 and 0.525) respectively.The portes (Mahdi and McLeod, 2012) package needs to be installed in order to perform tests of independence based on mLB statistic: > library(portes) > LjungBox (at, c(6, 12, 22)) Assuming that the bivariate log returns follows a VAR model and employing the AIC to choose its best order, we obtain that a VAR(2) model fits the data well.Figure 5 shows the ACF plots (upper panel) and ADCF plots (lower panel) of the residuals after fitting a VAR(2) model to the original bivariate log return series using the function VAR() from the MTS (Tsay, 2015) package.In contrast to the ACF plot, the ADCF plot still indicates some dependence among the residuals.Constructing tests of independence based on T n and mLB for the same choices of bandwidth, p = 6, 12, 22, we confirm this visual result.In particular, employing a Bartlett kernel, T n statistic gives low p-values (0.036, 0.018 and 0.034 respectively) whereas the mLB statistic yields large p-values (0.669, 0.958 and 0.806 respectively).The calls for the plots of Figure 5

TheFigure 2 :
Figure 2: Sample ACF, PACF and ADCF plots of the mortality residuals of model (18) indicating that the new residuals can be taken as white noise.

Figure 3 :Figure 4 :
Figure 3: (a) The sample ACF of the original series.(b) The sample ADCF of the original series.

TheFigure 5 :
Figure 5: (a) The sample ACF and (b) sample ADCF of the residuals after fitting VAR(2) model to the original series.

Table 1 :
Functions in dCovTS The multivariate tests of independence based on T n and T n are performed via mADCVtest() and mADCFtest() respectively in dCovTS package.The R Journal Vol.8/2, December 2016 ISSN 2073-4859