distance covariance analysis

10
Distance Covariance Analysis Benjamin R. Cowley 1 João D. Semedo 1 Amin Zandvakili 2 Matthew A. Smith 3 Adam Kohn 4 Byron M. Yu 1 1 Carnegie Mellon University 2 Brown University 3 University of Pittsburgh 4 Albert Einstein College of Medicine Abstract We propose a dimensionality reduction method to identify linear projections that capture interac- tions between two or more sets of variables. The method, distance covariance analysis (DCA), can detect both linear and nonlinear relationships, and can take dependent variables into account. On previous testbeds and a new testbed that system- atically assesses the ability to detect both linear and nonlinear interactions, DCA performs better than or comparable to existing methods, while being one of the fastest methods. To showcase the versatility of DCA, we also applied it to three different neurophysiological datasets. 1 Introduction We consider the problem of understanding interactions be- tween multiple sets of variables. This problem arises, for example, when studying interactions between populations of neurons in different brain areas (Semedo et al., 2014) or between different groups of genes (Winkelmann et al., 2007). These interactions are likely nonlinear (e.g., a gat- ing mechanism between brain areas), and can be captured by a nonlinear dimensionality reduction method, such as kernel canonical correlation analysis (KCCA) (Hardoon et al., 2004; Bach and Jordan, 2002). However, nonlin- ear dimensionality reduction methods have two important limitations. First, the amount of data that is collected in real-world experiments is often insufficient to sample the high-dimensional space densely enough for many of these methods (Van Der Maaten et al., 2009; Cunningham and Yu, 2014). Second, most nonlinear methods provide only a low-dimensional embedding, but do not provide a direct mapping from the low-dimensional embedding to the high- dimensional data space. As a result, it is difficult to compare the topology of different low-dimensional spaces. For these reasons, many scientific (e.g., neuroscience or genetics) studies rely on linear dimensionality reduction methods, such as principal component analysis (PCA) and canonical Proceedings of the 20 th International Conference on Artificial In- telligence and Statistics (AISTATS) 2017, Fort Lauderdale, Florida, USA. JMLR: W&CP volume 54. Copyright 2017 by the author(s). correlation analysis (CCA) (Witten and Tibshirani, 2009; Cunningham and Yu, 2014; Kobak et al., 2016; Cowley et al., 2016). Recently, methods that identify linear projections have been developed that can detect both linear and nonlinear interac- tions for multiple sets of variables. For example, hsic-CCA (Chang et al., 2013) maximizes a kernel-based correlational statistic called the Hilbert-Schmidt independence criterion (HSIC) (Gretton et al., 2007), and is a hybrid between CCA, which identifies linear projections but can only detect linear interactions, and KCCA, which can detect both linear and nonlinear interactions but identifies nonlinear projections. Thus, hsic-CCA has the interpretability of CCA as well as KCCA’s ability to detect nonlinear relationships. Still, hsic-CCA is limited to identifying dimensions for two sets of variables, and cannot be used to identify dimensions for three or more sets of variables. In this work, we propose distance covariance analysis (DCA), a dimensionality reduction method to identify linear projections that maximize the Euclidean-based correlational statistic distance covariance (Székely and Rizzo, 2009). As with HSIC, distance covariance can detect linear and nonlin- ear relationships (Sejdinovic et al., 2013). DCA has several important advantages over existing linear methods that can detect both linear and nonlinear relationships, such as hsic- CCA. First, DCA can identify dimensions for more than two sets of variables. Second, DCA can take into account dependent variables for which dimensions are not identified. Finally, DCA is computationally fast—in some cases, or- ders of magnitude faster than competing methods—without sacrificing performance. DCA can be applied to continuous and categorical variables, order the identified dimensions based on the strength of interaction, and scale to many vari- ables and samples. Using simulated data for one, two, and multiple sets of variables, we found that DCA performed better than or comparable to existing methods, while being one of the fastest methods. We then applied DCA to real data in three different neuroscientific contexts. 2 Distance covariance Distance covariance is a statistic that tests for independence between paired random vectors X R p and Y R q , and can detect linear and nonlinear relationships between X and Y (Székely and Rizzo, 2009). The intuition is that

Upload: others

Post on 15-Nov-2021

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Distance Covariance Analysis

Distance Covariance Analysis

Benjamin R. Cowley1 João D. Semedo1 Amin Zandvakili2 Matthew A. Smith3 Adam Kohn4 Byron M. Yu1

1Carnegie Mellon University 2Brown University 3University of Pittsburgh 4Albert Einstein College of Medicine

Abstract

We propose a dimensionality reduction methodto identify linear projections that capture interac-tions between two or more sets of variables. Themethod, distance covariance analysis (DCA), candetect both linear and nonlinear relationships, andcan take dependent variables into account. Onprevious testbeds and a new testbed that system-atically assesses the ability to detect both linearand nonlinear interactions, DCA performs betterthan or comparable to existing methods, whilebeing one of the fastest methods. To showcasethe versatility of DCA, we also applied it to threedifferent neurophysiological datasets.

1 Introduction

We consider the problem of understanding interactions be-tween multiple sets of variables. This problem arises, forexample, when studying interactions between populationsof neurons in different brain areas (Semedo et al., 2014)or between different groups of genes (Winkelmann et al.,2007). These interactions are likely nonlinear (e.g., a gat-ing mechanism between brain areas), and can be capturedby a nonlinear dimensionality reduction method, such askernel canonical correlation analysis (KCCA) (Hardoonet al., 2004; Bach and Jordan, 2002). However, nonlin-ear dimensionality reduction methods have two importantlimitations. First, the amount of data that is collected inreal-world experiments is often insufficient to sample thehigh-dimensional space densely enough for many of thesemethods (Van Der Maaten et al., 2009; Cunningham andYu, 2014). Second, most nonlinear methods provide onlya low-dimensional embedding, but do not provide a directmapping from the low-dimensional embedding to the high-dimensional data space. As a result, it is difficult to comparethe topology of different low-dimensional spaces. For thesereasons, many scientific (e.g., neuroscience or genetics)studies rely on linear dimensionality reduction methods,such as principal component analysis (PCA) and canonical

Proceedings of the 20th International Conference on Artificial In-telligence and Statistics (AISTATS) 2017, Fort Lauderdale, Florida,USA. JMLR: W&CP volume 54. Copyright 2017 by the author(s).

correlation analysis (CCA) (Witten and Tibshirani, 2009;Cunningham and Yu, 2014; Kobak et al., 2016; Cowleyet al., 2016).

Recently, methods that identify linear projections have beendeveloped that can detect both linear and nonlinear interac-tions for multiple sets of variables. For example, hsic-CCA(Chang et al., 2013) maximizes a kernel-based correlationalstatistic called the Hilbert-Schmidt independence criterion(HSIC) (Gretton et al., 2007), and is a hybrid between CCA,which identifies linear projections but can only detect linearinteractions, and KCCA, which can detect both linear andnonlinear interactions but identifies nonlinear projections.Thus, hsic-CCA has the interpretability of CCA as wellas KCCA’s ability to detect nonlinear relationships. Still,hsic-CCA is limited to identifying dimensions for two setsof variables, and cannot be used to identify dimensions forthree or more sets of variables.

In this work, we propose distance covariance analysis(DCA), a dimensionality reduction method to identify linearprojections that maximize the Euclidean-based correlationalstatistic distance covariance (Székely and Rizzo, 2009). Aswith HSIC, distance covariance can detect linear and nonlin-ear relationships (Sejdinovic et al., 2013). DCA has severalimportant advantages over existing linear methods that candetect both linear and nonlinear relationships, such as hsic-CCA. First, DCA can identify dimensions for more thantwo sets of variables. Second, DCA can take into accountdependent variables for which dimensions are not identified.Finally, DCA is computationally fast—in some cases, or-ders of magnitude faster than competing methods—withoutsacrificing performance. DCA can be applied to continuousand categorical variables, order the identified dimensionsbased on the strength of interaction, and scale to many vari-ables and samples. Using simulated data for one, two, andmultiple sets of variables, we found that DCA performedbetter than or comparable to existing methods, while beingone of the fastest methods. We then applied DCA to realdata in three different neuroscientific contexts.

2 Distance covariance

Distance covariance is a statistic that tests for independencebetween paired random vectors X ∈ Rp and Y ∈ Rq, andcan detect linear and nonlinear relationships between Xand Y (Székely and Rizzo, 2009). The intuition is that

Page 2: Distance Covariance Analysis

Distance Covariance Analysis

if there exists a relationship between X and Y , then fortwo similar samples Xi, Xj ∈ Rp, the two correspond-ing samples Yi, Yj ∈ Rq should also be similar. In otherwords, the Euclidean distance between Xi and Xj covarieswith that of Yi and Yj . To compute the sample distancecovariance ν(X,Y ) for N samples, one first computes theN × N distance matrices DX and DY for X and Y , re-spectively, where DX

ij = ‖Xi −Xj‖2 for i, j = 1, . . . , N .DY is computed in a similar manner. To take the covari-ance between distance matrices DX and DY , the row, col-umn, and matrix means must all be zero. This is achievedby computing the re-centered distance matrix RX , whereRXij = DX

ij − D̄X·j − D̄X

i· + D̄X·· and the D̄X terms are the

row, column, and matrix means. RY is defined in a similarmanner. The (squared) distance covariance ν2(X,Y ), ascalar, is then computed as:

ν2(X,Y ) =1

N2

N∑i,j=1

RXijRYij (1)

If ν = 0, then X and Y are independent (Székely andRizzo, 2009). The formulation of distance covariance uti-lizes both small and large Euclidean distances, in contrastto the locality assumption of many nonlinear dimensionalityreduction methods (Van Der Maaten et al., 2009). Whereasnonlinear dimensionality reduction methods seek to identifya nonlinear manifold, distance covariance seeks to detectrelationships between sets of variables.

3 Optimization framework for DCA

In this section, we first formulate the DCA optimizationproblem for identifying a dimension1 of X that has thegreatest distance covariance with Y . We then extend thisformulation for multiple sets of variables by identifying adimension for each set that has the greatest distance covari-ance with all other sets. In Section 4, we propose the DCAalgorithm to identify orthonormal linear dimensions orderedby decreasing distance covariance for each set of variables.

3.1 Identifying a DCA dimension for one set ofvariables

Consider maximizing the distance covariance between uTXand Y with respect to dimension u ∈ Rp. We compute the(squared) distance covariance ν2(uTX,Y ) defined in (1),with re-centered distance matrix RX(u) for uTX . Theoptimization problem is:

maxu

‖u‖≤1

1

N2

N∑i,j=1

RYijRXij (u) (2)

1In this work, we use the phrase “linear dimensions” or “di-mensions” of a random vector X ∈ Rp to refer to either a setof orthonormal basis vectors that define a subspace in Rp, or theprojection of X onto those vectors, depending on the context.

This problem was proposed in Sheng and Yin (2013), whereit was proven that the optimal solution u∗ is a consistentestimator of β ∈ Rp such that X is independent of Y givenβTX . Similar guarantees exist for HSIC-related methods,such as kernel dimensionality reduction (KDR) (Fukumizuet al., 2004). However, Sheng and Yin (2013) only con-sidered the case of identifying one dimension for one setof variables, and optimized with an approximate-gradientmethod (Matlab’s fmincon).

Instead, we optimize this problem using projected gradientdescent with backtracking line search. The gradient of theobjective function with respect to u is:

∂ν2

du=

1

N2

N∑i,j=1

RYij(δij(u)− δ̄·j(u)− δ̄i·(u) + δ̄··(u))

(3)where δij(u) = (Xi −Xj) sign(uT (Xi −Xj)) and the δ̄terms are the derivatives of the row, column, and matrixmeans that are used to re-center the distance matrix. Forlarge numbers of samples, we can also make use of the factthat each gradient step is computationally inexpensive toemploy stochastic projected gradient descent (with a mo-mentum term (Hu et al., 2009) and a decaying learning rateτ = 0.9).

We found that projected gradient descent performed betterand was faster than other optimization approaches, such asStiefel manifold optimization (Cunningham and Ghahra-mani, 2015). This is likely the case because we only opti-mize one dimension at a time, and do not optimize directlyfor multiple dimensions (see Section 4).

3.2 Identifying DCA dimensions for multiple sets ofvariables

Consider identifying dimensions u1 ∈ Rp1 and u2 ∈ Rp2for two sets of variables X1 ∈ Rp1 and X2 ∈ Rp2 , wherep1 need not equal p2, that maximize the distance covarianceby extending (2):

maxu1,u2

‖u1‖,‖u2‖≤1

1

N2

N∑i,j=1

R1ij(u

1)R2ij(u

2) (4)

To optimize, we alternate optimizing u1 and u2, wherebyon each iteration we first fix u2 and optimize for u1, thenfix u1 and optimize for u2. Because of the symmetry of theobjective function, each alternating optimization reduces tosolving (2).

To identify dimensions for multiple sets of variables, weextend the definition of distance covariance in (1) to cap-ture pairwise dataset interactions across M sets of variablesX1, . . . , XM (with Xm ∈ Rpm), where each set may con-tain a different number of variables:

ν(X1, . . . , XM ) =1(M2

) ∑1≤m<n≤M

ν(Xm, Xn) (5)

Page 3: Distance Covariance Analysis

Cowley, Semedo, Zandvakili, Smith, Kohn, Yu

Using (5), we extend the optimization problem of (4) tomultiple sets of variables, where we desire one dimensionfor each set of variables that maximizes the distance co-variance. We can also include information from Q setsof dependent variables Y 1, . . . , Y Q for which we are notinterested in identifying dimensions but are interested indetecting their relationship with dimensions of each Xm.An example of this is a neuroscientific experiment where weidentify dimensions of the recorded activity of neurons thatare related across M subjects (X1, . . . , XM ) and related toboth stimulus (Y 1) and behavioral (Y 2) information.

We seek to identify dimensions u1, . . . ,uM , whereum ∈ Rpm , that maximize the distance covarianceν(u1TX1, . . . ,uM

TXM , Y 1, . . . , Y Q). Using (5), the op-

timization problem is:

maxu1,...,uM

‖um‖≤1

1(M2

) 1

N2

∑1≤m<n≤M

〈Rm(um), Rn(un)〉

+1

M

1

N2

M∑m=1

〈Rm(um), RD〉 (6)

where Rm(um) is the re-centered distance matrix ofumTXm, 〈Rm, Rn〉 =

∑ij R

mijR

nij , and RD =

1Q

∑Qq=1R

q (i.e., the average of the re-centered distancematrices R1, . . . , RQ of the sets of dependent variablesY 1, . . . , Y Q). The first term is the distance covariance formultiple sets of variables as defined in (5), and the secondterm is the distance covariance between each set of variablesand the sets of dependent variables. Similar to optimizingfor two sets of variables, we optimize each um in an al-ternating manner which reduces solving (6) to solving (2)because we only consider terms that include um.

4 DCA algorithm

For the optimization problem (6), we identify only one di-mension for each set of variables. We now present the DCAalgorithm (Algorithm 1), which identifies a set of DCAdimensions ordered by decreasing distance covariance foreach set of variables. Given K desired DCA dimensions,DCA identifies the kth DCA dimension umk for each of theM datasets by iteratively optimizing u1

k, . . . ,uMk in (6) un-

til some criterion is reached (e.g., the fraction of changein the objective function for two consecutive iterations isless than some ε). Then, the data are projected onto theorthogonal subspace of the k previously-identified dimen-sions before optimizing for the (k + 1)th DCA dimension.This ensures that all subsequently-identified dimensions areorthogonal to the previously-identified dimensions. DCAreturns the identified dimensions as columns in the matricesU1, . . . , UM , where Um ∈ Rpm×K , and the correspondingordered distance covariances d1, . . . , dK .

To determine the number of DCA dimensions needed, onecan test if the distance covariance of the kth dimension is

Algorithm 1: DCA algorithm

Input: {X1, . . . , XM}, {Y 1, . . . , Y Q}, K desired dimsOutput: {U1, . . . , UM}, {d1, . . . , dK}initialize {U1, . . . , UM} randomly;for k = 1, . . . ,K do

while criterion not reached dofor m = 1, . . . ,M do

umk ←max ν(u1

kTX1, . . . ,uMk

TXM , Y 1, . . . , Y Q)

w.r.t. umk s.t. ‖umk ‖2 ≤ 1end

enddk ← ν(u1

kTX1, . . . ,uMk

TXM , Y 1, . . . , Y Q);

for each of the M datasets, Um(:, k)← umk /‖umk ‖2;for each of the M datasets, Xm ← project Xm ontoorthogonal space of Um(:, 1:k);

end

significant by a permutation test. Samples are first projectedonto the orthogonal space of the previously-identified (k−1)dimensions, because those dimensions are not consideredwhen optimizing the kth dimension. Then, the samples areshuffled within datasets to break any relationships acrossdatasets. A dimension is statistically significant if its dis-tance covariance is greater than a large percentage of thedistance covariances for many shuffled runs (e.g., 95% forsignificance level p = 0.05)

5 Performance on previous testbeds

We compared the performance of DCA to existing methodson testbeds used in previous work. We first considered thesetting of identifying dimensions for X that are related toY . We replicated the testbed used for KDR (Fukumizuand Leng, 2014), which included five different relationshipsbetween X and Y , ranging from sinusoidal to a 4th-degreepolynomial (Fig. 1A). The five simulations are labeled as“A”, “B”, “C-a”, “C-b”, and “D”, matching the labeling inFukumizu and Leng (2014). Each simulation had 10 or50 variables, 1,000 samples, and a ground truth β whosecolumns determined which dimensions of X related to Y .

We then measured performance by computing the meanprinicipal angle between β and the identified β̂. Existingmethods included the HSIC-based methods KDR (Fuku-mizu and Leng, 2014) and supervised PCA (SPCA) (Bar-shan et al., 2011), the distance-based method superviseddistance preserving projections (SDPP) (Zhu et al., 2013),the distance covariance-based method DCOV (Sheng andYin, 2016), and as a control, PCA. Note that DCA, whichoptimizes dimensions sequentially, is a statistically differentmethod than DCOV, which optimizes for all dimensions atonce. For existing methods across all testbeds in this work,we used publicly available code cited by the methods’ cor-

Page 4: Distance Covariance Analysis

Distance Covariance Analysis

A B C-a C-b D

90˚

β̂, β

A 90˚

linear sine circle

DCAKDRDCOVSDPPSPCAPCA

DCASCAhsic-CCAABCACCAPLSLSCDA

B

lowerror

Figure 1: (A)KDR testbeds.(B) hsic-CCAtestbeds. Errorbars: standarddeviation over100 runs.

responding papers, as well as their suggested procedures tofit hyperparameters, such as kernel bandwidths. We foundthat DCA was among the best performing methods for eachsimulation (Fig. 1A, red). Simulation D showed worse per-formance for all methods compared to the other simulationsbecause it required identifying 10 dimensions for 50 vari-ables, while the other methods required identifying only afew dimensions for 10 variables.

Next, we considered the setting of identifying dimensionsfor both X and Y . We replicated the testbed used for hsic-CCA (Chang et al., 2013), which comprised three differentrelationships between variables in X (5 variables) and Y(4 variables) with 1,000 samples (Fig. 1B). We measuredperformance by computing the principal angles between theground truth dimensions β and the identified dimensions β̂for both X and Y , and taking the average. Existing methodsincluded those that can detect only linear interactions, suchas CCA (Hotelling, 1936) and partial least squares (PLS)(Höskuldsson, 1988; Helland, 1988), as well as methods thatcan detect both linear and nonlinear interactions by maxi-mizing a correlational statistic. These methods include leastsquares canonical dependency analysis (LSCDA, minimiz-ing the squared-loss mutual information) (Karasuyama andSugiyama, 2012), hsic-CCA (maximing the kernel-basedHSIC statistic) (Chang et al., 2013), semiparametric canon-ical analysis (SCA, minimizing the prediction error of alocal polynomial smoother) (Xia, 2008), and AB-canonicalanalysis (ABCA, maximizing the alpha-beta divergence)(Mandal and Cichocki, 2013).

Similar to the results in Fig. 1A, we found that DCA wasamong the best performing methods for the “linear” and“sine” simulations. The “circle” simulation proved chal-lenging for all methods, with ABCA and hsic-CCA havingthe best mean performance (but within the error margin forDCA). The results of the two testbeds in Fig. 1 demonstratethat DCA is highly competitive with existing methods atdetecting both linear and nonlinear interactions. However,these simulations tested only a small handful of linear andnonlinear relationships, and it is unclear how well theseresults generalize to other types of nonlinearities.

6 Performance on novel testbeds

Because the previous testbeds probed a small number ofnonlinearities, we designed a testbed that allowed us tosystematically vary the relationship between datasets from

linear to highly nonlinear. Because existing methods are typ-ically only applicable to one setting (identifying dimensionsfor one, two, or multiple sets of variables), we tested DCAseparately on the three different settings for comparison.None of the existing methods can be applied to all threesettings, which highlights the versatility of DCA.

6.1 Identifying dimensions for one set of variables

To systematically vary the relationship between X and Y ,we generated the data (1,000 samples for each of 10 runs)as follows. Let X = [x1, . . . , x50]T , where xi ∼ N (0, 1),and let β ∈ R50×5, where each element is drawn from astandard Gaussian. The columns β1, . . . , β5 are then or-thonormalized. Define each element of Y = [y1, . . . , y5]T

as yi = sin( 2πα fβi

TX). We chose the sine function be-cause for f = 1, it is approximately linear (i.e., sin(x) ≈ xfor [−π4 ,

π4 ]), and increases in nonlinearity with increas-

ing f . To ensure that βTi X did not exceed the domainof [−π4 ,

π4 ], we included a normalization constant α =

8√

50 · ‖[X1 . . . X1000]‖∞. The 45 dimensions in X notrelated to Y represent noise, although further noise couldbe added to Y . We measure the performance of a methodby comparing the mean principal angle between identifieddimensions β̂ and the ground truth β.

We tested DCA against existing methods that identified di-mensions forX related to Y . We found that DCA performedwell (error < 10°) for low frequencies, and outperformedthe other methods for 60 < f < 100 (Fig. 2A, top panel).DCA also ran remarkably fast— orders of magnitude fasterthan KDR and SPCA, which require fitting kernel band-widths, as well as DCOV, which relies on an approximategradient descent method (Fig. 2A, bottom panel). We con-firmed that fitting kernel bandwidths to the data was thecause of the large computation time for KDR and SPCA byselecting a kernel bandwidth σ a priori (equal to the medianof the Euclidean distances between data points). In this case,KDR-σ and SPCA-σ required similar running times as DCA(Fig. 2A, bottom panel). We note that for f ≤ 40, SDPPand KDR-σ performed better than DCA with comparablerunning times. Thus, these methods are more appropriatefor detecting linear interactions between X and Y , whileDCA is more appropriate for detecting nonlinear interac-tions. Since DCA is a nonconvex optimization problem, weconfirmed that for 100 random starts for the same X andY (at f = 30), the solutions were consistent, with mean

Page 5: Distance Covariance Analysis

Cowley, Semedo, Zandvakili, Smith, Kohn, Yu

1 20 40 60 80 100 120

90˚

PCAKDRSDPPSPCASPCA-σKDR-σDCOVDCA

β̂, β

lowerror

A one dataset

PLShsic-CCACCASCALSCDAABCADCA

two datasetsB C multiple datasets

h-align.

GCAgCCA

2 4 6 8 10 12 2014 16 18

DCADCA-stoch(5000 samples)

80˚

60˚

40˚

20˚

10˚

90˚80˚

60˚

40˚

20˚

10˚

90˚80˚

60˚

40˚

20˚

10˚

0˚1 20 40 60 80 100 120

number of datasets2 4 6 8 10 12 2014 16 18

frequency, f

1 20 40 60 80 100 120

frequency, f

1 20 40 60 80 100 12010-3

time(seconds)

10-1

101

103

105

PCA

SDPPSPCA-σKDR-σDCA

DCOVSPCAKDR

10-3

10-1

101

103

105

PLS

hsic-CCA

CCA

SCA

LSCDA

ABCA

DCA

10-3

10-1

101

103

105

1 min

1 hr

1 min

1 hr

1 min

1 hr

h-align.gCCA

DCA

DCA-stoch(5000 samples)

GCA

Figure 2: Top panels show error (measured by angle of overlap) for identifying dimensions for (A) one set, (B) two sets, and(C) multiple sets of variables. We varied the degree of nonlinearity in A and B, and the number of datasets in C. Bottompanels show running time in log scale. Error bars: standard deviations over 10 runs.

principal angle 7.78°± 0.27°.

6.2 Identifying dimensions for two sets of variables

In the case of two sets of variables, we sought to identifydimensions for both X and Y . We used the same simulateddata as in Section 6.1, and assessed how well a methodrecovered β, the dimensions of X related to Y (Fig. 2B).There are three main findings. First, DCA performed well(error < 10°) for low frequencies and outperformed theother methods for 80 < f < 110. CCA, SCA, and ABCAwere better able to capture linear interactions than DCA,although ABCA was much slower. We also confirmedthat DCA performed well for non-orthonormalized β’s andadded Gaussian noise to Y (Supp. Fig. 1). Second, DCAperformed better when it removed previously-identified di-mensions of Y that could mask other relevant dimensionsof Y (Fig. 2B, red curve) than when DCA did not identifydimensions of Y (Fig. 2A, red curve, e.g., compare withFig. 2B for f = 90). This is an advantage shared by SCA,ABCA, and hsic-CCA (Chang et al., 2013). Finally, DCAwas fast—an order of magnitude faster than some competingmethods (Fig. 2B, bottom panel).

6.3 Identifying dimensions for multiple sets ofvariables

In the case of multiple sets of variables, we aimed to iden-tify dimensions for up to M = 20 datasets. To test per-formance, we extended the previous testbed in the follow-ing way. First, we generated 500 samples of Z ∈ R5,where each element was drawn from a standard Gaussian.Then, for each set of variablesX1, . . . , XM ∈ R10, we gen-

erated a random orthonormal basis βm = [βm1 , . . . , βm5 ],

where βmi ∈ R5. The first five of ten variables in the mthdatasetXm = [xm1 , . . . , x

m10]T were xmi = sin( 2π

α fβmiTZ)

for i = 1, . . . , 5, m = 1, . . . ,M , f = 30, and α =8√

5 · ‖[Z1 . . . Z500]‖∞. The remaining five variables ofXm were shuffled versions of the first five variables (shuf-fled across samples). By generating the data in this way,we ensured that only the first five variables in each datasetwere related across datasets, and we defined ground truthto be any 5-d subspace spanned by the first five variables.To measure performance, we computed the mean principalangle between the top five identified dimensions and the firstfive standard basis dimensions {e1, . . . , e5}, and averagedover the M datasets.

We found that as the number of datasets increased, the per-formance of most methods improved (Fig. 2C, top panel).This is because the methods had access to more samples tobetter detect interactions between datasets. DCA showedbetter performance than hyperalignment (“h-align.”) (Haxbyet al., 2011), whose PCA step returns random dimensionsbecause all variables in Xm have equal variance. We alsotested generalized CCA (gCCA) (Kettenring, 1971), whichcan only detect linear interactions between datasets. gCCAperformed better than hyperalignment, presumably becauseit detected weak linear interactions between datasets, butperformed worse than DCA. Finally, we tested generalizedcanonical analysis (GCA), a method that can detect non-linear interactions between multiple datasets (Iaci et al.,2010), but this method performed worse and was orders ofmagnitude slower than DCA (Fig. 2C, bottom panel). Wealso tested the scalability of DCA by increasing the num-ber of samples from 500 to 5,000. As expected, DCA with

Page 6: Distance Covariance Analysis

Distance Covariance Analysis

DCA dimension 1

4

2

0

-2

2 4 6 8 10

5

3

1

-1

0 2 4 6 8

DCA

dim

ensi

on 2

DCA dimension 1

Y = cos(2θ)sin(2θ)

Y = θA B

PCA dimension 1

PCA

dim

ensi

on 2

4

2

0

-2

-4420-2-4 6

SSE = 9.0 ± 0.2

SSE = 4.4 ± 0.1

SSE = 4.7 ± 0.1

Figure 3: (A) PCA projection ofneural responses overlaid with cor-responding grating images. Red-outlined gratings have angles 90°apart. SSE: sum of squared error.(B) DCA projections for differentY . Same data and red-outlinedgratings as in (A).

stochastic projected gradient descent outperformed the othermethods at detecting the nonlinear relationships betweendatasets (Fig. 2C, “DCA-stoch”).

7 Applications

To demonstrate how DCA can be applied to real-world data,we apply DCA to three datasets comprising recordings fromtens of neurons in primary visual cortex that represent thethree different settings (identifying dimensions for one, two,and multiple sets of variables). Because we do not knowground truth for these datasets, we do not compare DCAwith all existing methods. Here, the purpose is to highlighthow DCA returns sensible results in all three settings.

7.1 Identifying stimulus-related dimensions of neuralpopulation activity

When recording the activity of neurons in response to asensory stimulus, there are typically aspects of the neuralresponses that covary with the stimulus and those that do notcovary with the stimulus. Having recorded from a popula-tion of neurons, we can define a multi-dimensional activityspace, where each axis represents the activity level of eachneuron (Cunningham and Yu, 2014). It is of interest to iden-tify dimensions in this space in which the population activitycovaries with the stimulus (Kobak et al., 2016; Mante et al.,2013). For example, one can record from neurons in primaryvisual cortex (V1) and seek dimensions in which the popu-lation activity covaries with the orientation of moving bars.We analyzed a dataset in which we recorded the activity of61 V1 neurons in response to drifting sinusoidal gratingspresented for 300 ms each with the same spatial frequencyand 49 different orientation angles (equally spaced between0° and 180°) (Kelly et al., 2010). We computed the meanspike counts taken in 300 ms bins and averaged over 120trials.

If there were a strong relationship between the neural activ-ity and grating orientation, we would expect to see nearbyneural responses encode similar grating orientations. How-ever, when we applied PCA to the trial-averaged populationactivity (Fig. 3A), we did not observe this similarity forall nearby responses (Fig. 3A, red-outlined gratings). Toprovide supervision, we sought to identify dimensions ofthe trial-averaged population activity X (61 neurons × 49orientations) that were most related to Y , the representation

of grating orientation. Because we did not seek to identifydimensions in Y , this example is in the setting of identifyingdimensions for one dataset.

The mean response of a V1 neuron f(θ) to different orien-tations θ can be described by a cosine tuning model with apreferred orientation θpref (Shriki et al., 2012). If V1 neuronswere truly cosine-tuned, then f(θ) ∝ cos(2(θ − θpref)) =α1 cos(2θ) + α2 sin(2θ), where α1 and α2 depend on θpref.This motivates letting Y = [cos(2θ), sin(2θ)]T to define alinear relationship between X and Y . DCA identified twodimensions in firing rate space that strongly capture orienta-tion (Fig. 3B, left panel). However, if instead we representedorientation directly as Y = θ (therefore not utilizing domainknowledge), X and Y would have a nonlinear relationship.For this representation of orientation, DCA was still ableto identify two dimensions that strongly capture orientation(Fig. 3B, right panel). For both cases, the two DCA dimen-sions had nearly half of the cross-validated sum of squarederror (SSE), computed with linear ridge regression, than thatof the two PCA dimensions. This highlights the ability ofDCA to detect both linear and nonlinear relationships andreturn sensible results.

7.2 Identifying nonlinear relationships betweenneural population activity recorded in twodistinct brain areas

An open question in neuroscience is how populations of neu-rons interact across different brain areas. Previous studieshave examined linear interactions between brain areas V1and V2 (Semedo et al., 2014). Here, we attempt to identifynonlinear interactions between V1 and V2. We analyzeda dataset in which we presented drifting sinusoidal grat-ings (8 orientations, each with 400 trials; 1 sec stimuluspresentation for each trial) while simultaneously recordingpopulation activity from 75 V1 neurons and 22 V2 neurons(Zandvakili and Kohn, 2015). To focus on the moment-by-moment interactions, we computed the residuals of theactivity by subtracting the mean spike counts from the rawspike counts (100 ms bins) for each orientation.

We asked whether DCA could identify a relationship be-tween V1 activity and V2 activity after the linear relation-ship between them was removed. If so, this would implythat a nonlinear relationship exists between V1 and V2, andcould be identified by DCA. We first applied CCA, PLS,

Page 7: Distance Covariance Analysis

Cowley, Semedo, Zandvakili, Smith, Kohn, Yu

dim

ensi

onal

ity

8

7

6

5

4

3

2

1

0

8

7

6

5

4

3

2

1

0CCA PLS DCA KCCA CCA PLS DCA KCCA

V1 V2, residuals(linear + nonlinear)

V1 V2, residuals(nonlinear only)

90˚

70˚

50˚

30˚

10˚

chance

A B C D

βPLS βDCA βDCA-nonlin

�βDCA

βPLS

βDCA-nonlin

βDCA

�βDCA-nonlin

βPLS

mea

n pr

inci

pal a

ngle

−20 0 20−10

0

10

20

−20 0 20−10

−5

0

5

10

−10 0 100

2

4

6

−10 0 100

5

10

V2 --

- DCA

dim

1

V1 --- DCA dim 1

V1 --- DCA dim 1

V2 --

- var

ianc

e

real data Poisson model

V1 --- DCA dim 1

Figure 4: Dimensionality (A) between activity of V1 and V2 and (B) between the same activity, minus linear relationships.(C) Similarity between identified dimensions. (D) Top panels: Density plots of projections of the top DCA dimension of V1and V2 activity for one grating (left, same data as in B) and for data generated from a linear-Poisson model (right). Red(blue) areas denote a high (low) density of datapoints. Bottom panels: Variance of projected V2 activity was computed inbins with equal number of datapoints; green arrow shows an example bin.

DCA, and KCCA to the activity for each orientation. Wechose CCA and PLS because they can only detect linearinteractions, and KCCA because it can detect nonlinear in-teractions. Dimensionality was determined as described inSection 4 with a significance of p < 0.05. We found thatCCA, PLS, DCA, and KCCA all returned a dimensional-ity greater than zero (Fig. 4A), indicating that interactionsexist between V1 and V2. We then subtracted the linearcontribution of V1 from the V2 activity (identified withlinear ridge regression). We confirmed that CCA and PLS,both linear methods, identified zero dimensions for the V2activity that had no linear contribution from V1 (Fig. 4B).However, DCA identified 2 to 3 dimensions, suggesting thatnonlinear interactions exist between V1 and V2. KCCA alsoidentified a non-zero dimensionality (Fig. 4B), consistentwith DCA.

A key advantage of methods that identify linear projectionsis that they can address certain types of scientific questionsmore readily than nonlinear methods. For example, weasked if the linear and nonlinear interactions between V1and V2 occur along similar dimensions in the V1 activ-ity space. It is difficult for KCCA to address this ques-tion because it does not return a mapping between the low-dimensional embedding and the high-dimensional activityspace. In contrast, DCA, which identifies linear dimensionsbut can still detect nonlinear interactions, can readily be usedto address this question. We first computed the mean prin-cipal angle between the dimensions identified by PLS andDCA in Fig. 4A, and found that the dimensions overlappedmore than expected by chance (Fig. 4C, βDCA ∠ βPLS ,green bar lower than gray bar). This suggests that someDCA dimensions represent similar linear interactions asthose identified by PLS. Next, we asked if DCA returnedsimilar dimensions when considering the full activity (βDCA,Fig. 4A) versus the activity minus any linear contributions(βDCA-nonlin, Fig. 4B). As expected, the mean principal anglewas small compared to chance (Fig. 4C, βDCA-nonlin ∠ βDCA),

confirming that DCA detects similar nonlinear interactionsin both cases. Finally, we asked if the linear and nonlinearinteractions occur along similar dimensions. We found thatthe mean principal angle between the PLS dimensions andthe DCA-nonlinear dimensions was smaller than chance(Fig. 4C, βDCA-nonlin ∠ βPLS). This suggests that linear andnonlinear interactions do occur along similar dimensions.Similar results hold for CCA (albeit with larger principalangles, ~60°).

To gain intuition about the nonlinear interactions identifiedby DCA, we plotted the top DCA dimension for V1 versusthe top DCA dimension for V2 (Fig. 4D, top left, one repre-sentative grating). We noticed that the variance of the V2activity increased as the V1 activity increased—a nonlinear,heteroskedastic interaction (Fig. 4D, bottom left). We hy-pothesized that a linear-nonlinear-Poisson model, where V2activity is generated by a Poisson process whose rate is alinear projection of V1 activity passed through a hinge func-tion, could explain this relationship. Indeed, when applyingDCA to data generated from the linear-nonlinear-Poissonmodel, we found a similar trend as that of the real data(Fig. 4D, right panels).

7.3 Aligning neural population activity recordedfrom different subjects

The recording time (i.e., number of trials) in a given exper-imental session is typically limited by factors such as thesubject’s satiety or neural recording stability. To increasethe number of trials, one can consider combining many in-dividual datasets into one large dataset for analysis. Thequestion is how to combine the different datasets given thatpossibly different neurons are recorded in each dataset. Oneway is to align population activity recorded from differentsubjects, provided that the neurons are recorded in similarbrain locations. This is similar in spirit to methods that alignfMRI voxels across subjects (Haxby et al., 2011). DCA

Page 8: Distance Covariance Analysis

Distance Covariance Analysis

d1

d2o

o

o

o

monkey 1 monkey 2 monkey 3 monkey 4

A

B

4.3° 11.0° 14.5° 6.3°

Figure 5: Top twoDCA dimensions (A)of V1 population re-sponses to gratingswith 8 different orien-tations for 4 monkeysand (B) of the same V1responses but with ran-domly permuted orien-tation labels. Meanprincipal angles werecomputed between di-mensions in (A) and(B). Chance: ~83°.

is well-suited for alignment because of its ability to iden-tify dimensions that are similar across subjects and relatedto stimulus information, and its ability to detect nonlinearrelationships across subjects. To showcase DCA as an align-ment method, we analyzed a dataset in which V1 populationactivity was recorded from 4 different monkeys (111, 118,109, and 97 neurons, respectively) while drifting sinusoidalgratings (8 orientations, each with 300 trials; 1 sec stimuluspresentation for each trial) were presented (Zandvakili andKohn, 2015). We applied DCA to the 4 datasets (taken in1 sec bins). The ith trial for each monkey corresponded tothe same orientation (i = 1, . . . , 2400). Given no informa-tion about orientation, DCA was able to identify dimensionsof each monkey’s population activity that capture orien-tation (Fig. 5A), because these dimensions were the moststrongly related across monkeys. These dimensions wereapproximately linearly related because the ordering of theclusters around the circle was the same across monkeys (i.e.,the DCA dimensions could be rotated to align clusters basedon color).

To make the task of aligning population activity more diffi-cult, we introduced a nonlinear transformation by randomlypermuting the orientation labels across trials for each mon-key. Importantly, trials that previously had the same labelstill had the same label after permuting (i.e., we randomlypermuted the colors across clusters). After permuting, theith trial for one monkey might not have the same orientationas the ith trial for another monkey (i = 1, . . . , 2400). Asbefore, the color labels were not provided to DCA. DCAidentified remarkably similar dimensions across monkeys(Fig. 5B) as those without permutation (Fig. 5A), quanti-fied by the mean principal angle between the dimensions(chance angle: ~83°). Because the dimensions cannot sim-ply be rotated to align the colors of the clusters, this showsthat DCA is able to detect nonlinear relationships acrossdatasets. These results illustrate how DCA can align neuralactivity.

8 Discussion

We proposed DCA, a dimensionality reduction method thatcombines the interpretability of linear projections with theability to detect nonlinear interactions. The biggest advan-tage of DCA is its applicability to a wide range of problems,including identifying dimensions in one or more sets of vari-ables, with or without dependent variables. DCA is not reg-ularized, unlike kernel-based methods (e.g., KDR, SPCA,and hsic-CCA), whose bandwidth parameters provide aform of regularization. However, fitting the bandwidth wascomputationally demanding, and when a heuristic was usedto pre-select a kernel bandwidth, DCA was better able tocapture nonlinear interactions. In addition, DCA may bedirectly regularized by the use of penalties, akin to sparseCCA (Witten and Tibshirani, 2009).

We optimized for {u1, . . . ,uK} sequentially instead of di-rectly optimizing for the orthonormal basis U ∈ Rp×K . Thesequential approach, also used by other methods (Changet al., 2013; Xia, 2008; Iaci et al., 2010; Mandal and Ci-chocki, 2013), has the advantages of many smaller optimiza-tion spaces rather that one large optimization space, andthe removal of previously-identified dimensions that couldotherwise mask other relevant dimensions (cf. Section 6.2).Directly optimizing for U no longer orders dimensions byrelevance, making visualization and interpretation difficult.Still, directly optimizing for U can detect certain relation-ships between X and Y that would not be detected by thesequential approach (e.g., the continuous version of XOR:Y = sign(x1x2), where x1 and x2 are independent). Futurework can extend DCA to directly optimize for the subspaces.The DCA source code for Matlab and Python can be foundat https://bit.ly/dca_code.

Acknowledgments

This work was supported by NDSEG and RK Mellon Fel-lowships (B.R.C.), Bertucci Graduate Fellowship (J.D.S.),NIH EY022928 (M.A.S.), and Simons Collaboration on theGlobal Brain (A.K. and B.M.Y.).

Page 9: Distance Covariance Analysis

Cowley, Semedo, Zandvakili, Smith, Kohn, Yu

References

F. R. Bach and M. I. Jordan. Kernel independent componentanalysis. Journal of machine learning research, 3(Jul):1–48, 2002.

E. Barshan, A. Ghodsi, Z. Azimifar, and M. Z. Jahromi.Supervised principal component analysis: Visualization,classification and regression on subspaces and submani-folds. Pattern Recognition, 44(7):1357–1371, 2011.

B. Chang, U. Kruger, R. Kustra, and J. Zhang. Canonicalcorrelation analysis based on hilbert-schmidt indepen-dence criterion and centered kernel target alignment. InProceedings of The 30th International Conference onMachine Learning, pages 316–324, 2013.

B. R. Cowley, M. A. Smith, A. Kohn, and M. Y. Byron.Stimulus-driven population activity patterns in macaqueprimary visual cortex. PLOS Computational Biology, 12(12):e1005185, 2016.

J. P. Cunningham and Z. Ghahramani. Linear dimensionalityreduction: Survey, insights, and generalizations. Journalof Machine Learning Research, 16:2859–2900, 2015.

J. P. Cunningham and B. M. Yu. Dimensionality reductionfor large-scale neural recordings. Nature neuroscience,17(11):1500–1509, 2014.

K. Fukumizu and C. Leng. Gradient-based kernel dimen-sion reduction for regression. Journal of the AmericanStatistical Association, 109(505):359–370, 2014.

K. Fukumizu, F. R. Bach, and M. I. Jordan. Dimensional-ity reduction for supervised learning with reproducingkernel hilbert spaces. The Journal of Machine LearningResearch, 5:73–99, 2004.

A. Gretton, K. Fukumizu, C. H. Teo, L. Song, B. Schölkopf,and A. J. Smola. A kernel statistical test of independence.In Advances in neural information processing systems,pages 585–592, 2007.

D. R. Hardoon, S. Szedmak, and J. Shawe-Taylor. Canonicalcorrelation analysis: An overview with application tolearning methods. Neural computation, 16(12):2639–2664, 2004.

J. V. Haxby, J. S. Guntupalli, A. C. Connolly, Y. O.Halchenko, B. R. Conroy, M. I. Gobbini, M. Hanke, andP. J. Ramadge. A common, high-dimensional modelof the representational space in human ventral temporalcortex. Neuron, 72(2):404–416, 2011.

I. S. Helland. On the structure of partial least squares re-gression. Communications in statistics-Simulation andComputation, 17(2):581–607, 1988.

A. Höskuldsson. Pls regression methods. Journal of chemo-metrics, 2(3):211–228, 1988.

H. Hotelling. Relations between two sets of variates.Biometrika, 28(3/4):321–377, 1936.

C. Hu, W. Pan, and J. T. Kwok. Accelerated gradient meth-ods for stochastic optimization and online learning. In Ad-vances in Neural Information Processing Systems, pages781–789, 2009.

R. Iaci, T. Sriram, and X. Yin. Multivariate associationand dimension reduction: A generalization of canonicalcorrelation analysis. Biometrics, 66(4):1107–1118, 2010.

M. Karasuyama and M. Sugiyama. Canonical dependencyanalysis based on squared-loss mutual information. Neu-ral Networks, 34:46–55, 2012.

R. C. Kelly, M. A. Smith, R. E. Kass, and T. S. Lee. Localfield potentials indicate network state and account forneuronal response variability. Journal of computationalneuroscience, 29(3):567–579, 2010.

J. R. Kettenring. Canonical analysis of several sets of vari-ables. Biometrika, 58(3):433–451, 1971.

D. Kobak, W. Brendel, C. Constantinidis, C. E. Feierstein,A. Kepecs, Z. F. Mainen, X.-L. Qi, R. Romo, N. Uchida,and C. K. Machens. Demixed principal component anal-ysis of neural population data. eLife, 5:e10989, 2016.

A. Mandal and A. Cichocki. Non-linear canonical correla-tion analysis using alpha-beta divergence. Entropy, 15(7):2788–2804, 2013.

V. Mante, D. Sussillo, K. V. Shenoy, and W. T. Newsome.Context-dependent computation by recurrent dynamicsin prefrontal cortex. Nature, 503(7474):78–84, 2013.

D. Sejdinovic, B. Sriperumbudur, A. Gretton, and K. Fuku-mizu. Equivalence of distance-based and rkhs-basedstatistics in hypothesis testing. The Annals of Statistics,41(5):2263–2291, 2013.

J. Semedo, A. Zandvakili, A. Kohn, C. K. Machens, andB. M. Yu. Extracting latent structure from multiple inter-acting neural populations. In Advances in neural infor-mation processing systems, pages 2942–2950, 2014.

W. Sheng and X. Yin. Direction estimation in single-indexmodels via distance covariance. Journal of MultivariateAnalysis, 122:148–161, 2013.

W. Sheng and X. Yin. Sufficient dimension reduction via dis-tance covariance. Journal of Computational and Graphi-cal Statistics, 25(1):91–104, 2016.

O. Shriki, A. Kohn, and M. Shamir. Fast coding of orien-tation in primary visual cortex. PLoS Comput Biol, 8(6):e1002536, 2012.

G. J. Székely and M. L. Rizzo. Brownian distance covari-ance. The annals of applied statistics, 3(4):1236–1265,2009.

L. Van Der Maaten, E. Postma, and J. Van den Herik. Di-mensionality reduction: a comparative. J Mach LearnRes, 10:66–71, 2009.

J. Winkelmann, B. Schormair, P. Lichtner, S. Ripke,L. Xiong, S. Jalilzadeh, S. Fulda, B. Pütz, G. Eckstein,

Page 10: Distance Covariance Analysis

Distance Covariance Analysis

S. Hauk, et al. Genome-wide association study of restlesslegs syndrome identifies common variants in three ge-nomic regions. Nature genetics, 39(8):1000–1006, 2007.

D. M. Witten and R. J. Tibshirani. Extensions of sparsecanonical correlation analysis with applications to ge-nomic data. Statistical applications in genetics and molec-ular biology, 8(1):1–27, 2009.

Y. Xia. A semiparametric approach to canonical analysis.Journal of the Royal Statistical Society: Series B (Statis-tical Methodology), 70(3):519–543, 2008.

A. Zandvakili and A. Kohn. Coordinated neuronal activityenhances corticocortical communication. Neuron, 87(4):827–839, 2015.

Z. Zhu, T. Similä, and F. Corona. Supervised distancepreserving projections. Neural processing letters, 38(3):445–463, 2013.