Title: | Nonparametric Smoothing of Laplacian Graph Spectra |
---|---|
Description: | A nonparametric method to approximate Laplacian graph spectra of a network with ordered vertices. This provides a computationally efficient algorithm for obtaining an accurate and smooth estimate of the graph Laplacian basis. The approximation results can then be used for tasks like change point detection, k-sample testing, and so on. The primary reference is Mukhopadhyay, S. and Wang, K. (2018, Technical Report). |
Authors: | Subhadeep Mukhopadhyay, Kaijun Wang |
Maintainer: | Kaijun Wang <[email protected]> |
License: | GPL-2 |
Version: | 2.1 |
Built: | 2024-12-17 06:53:08 UTC |
Source: | CRAN |
This package provides an algorithm to approximate and smooth the Laplacian graph spectra of a network with ordered vertices using LP-nonparametric basis. The underlying theory yields a reduced order (compressive) characterization of spectral graph properties.
Mukhopadhyay, S. and Wang, K.
Maintainer: Kaijun Wang <[email protected]>
Mukhopadhyay, S. and Wang, K. (2018), "Graph Spectral Compression via Smoothing".
Mukhopadhyay, S. (2017+), "Unified Statistical Theory of Spectral Graph Analysis".
Mukhopadhyay, S. and Parzen, E. (2014), "LP Approach to Statistical Modeling", arXiv:1405.2601.
This function computes m
LP basis functions for the given discrete distribution p.dist
LP.basis(p.dist, m)
LP.basis(p.dist, m)
p.dist |
A vector of |
m |
An integer denoting the number of required LP basis functions |
A matrix of dimension .
Mukhopadhyay, S. and Wang, K.
Mukhopadhyay, S. and Parzen, E. (2014), "LP Approach to Statistical Modeling", arXiv:1405.2601.
##1.toy example: ##simulate a two sample locational difference normal data: X1<-matrix(rnorm(250,mean=0,sd=1),10,25) X2<-matrix(rnorm(250,mean=0.5,sd=1),10,25) X<-rbind(X1,X2) ## Adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## getting the basis pp<- rowSums(W)/sum(W) T<-LP.basis(pp,m=4) #plot the j-th LP basis for the two sample data (here we use j=1). j=1 plot(cumsum(pp),T[,j],type='s',xlab='',ylab='') ##2.Senate data ## Not run: data(senate) attach(senate) #create W matrix: (long computation) require(psych) W <- matrix(0,nrow(X),nrow(X)) for(i in 1:(nrow(X)-1)){ for(j in (i+1):nrow(X)) { W[i,j] <- psych::phi(table(X[i,],X[j,])) } } W = W + t(W) diag(W)<-0 #getting the basis: pp<- rowSums(W)/sum(W) T<-LP.basis(pp,m=4) #plot the j-th LP basis for senate data (here we use j=1). j=1 plot(cumsum(pp),T[,j],type='s',xlab='',ylab='') ## End(Not run)
##1.toy example: ##simulate a two sample locational difference normal data: X1<-matrix(rnorm(250,mean=0,sd=1),10,25) X2<-matrix(rnorm(250,mean=0.5,sd=1),10,25) X<-rbind(X1,X2) ## Adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## getting the basis pp<- rowSums(W)/sum(W) T<-LP.basis(pp,m=4) #plot the j-th LP basis for the two sample data (here we use j=1). j=1 plot(cumsum(pp),T[,j],type='s',xlab='',ylab='') ##2.Senate data ## Not run: data(senate) attach(senate) #create W matrix: (long computation) require(psych) W <- matrix(0,nrow(X),nrow(X)) for(i in 1:(nrow(X)-1)){ for(j in (i+1):nrow(X)) { W[i,j] <- psych::phi(table(X[i,],X[j,])) } } W = W + t(W) diag(W)<-0 #getting the basis: pp<- rowSums(W)/sum(W) T<-LP.basis(pp,m=4) #plot the j-th LP basis for senate data (here we use j=1). j=1 plot(cumsum(pp),T[,j],type='s',xlab='',ylab='') ## End(Not run)
Given adjacency matrix W
, this function perform a graph based test to determine whether there are different communities present in a graph of ordered vertices.
LP.struct.test(W, m = NULL, n.iter = 50)
LP.struct.test(W, m = NULL, n.iter = 50)
W |
A |
m |
Number of LP-nonparametric basis used for generating the test statistic, set to |
n.iter |
Iterations used for small sample correction, default is |
A list containing the following items:
stat |
The test statistic, which asymptotically follows a normal distribution with mean and variance mentioned in the reference. |
pval |
P-value for the test, small p-value means different communities may be present. |
Mukhopadhyay, S. and Wang, K.
Mukhopadhyay, S. and Wang, K. (2018), "Graph Spectral Compression via Smoothing".
##1.example: null case ##simulate a normal data with mean 0 and variance 1: X <-matrix(rnorm(500,mean=0,sd=1),20,25) ## Generate adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## test of structure: h0.test<-LP.struct.test(W, m = 4 , n.iter = 50) ###extract p-value: h0.test$pval ##2.example: two sample location alternative ##simulate a two sample locational difference normal data: X1<-matrix(rnorm(250,mean=0,sd=1),10,25) X2<-matrix(rnorm(250,mean=0.5,sd=1),10,25) X<-rbind(X1,X2) ## Generate adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## test of structure: h1.test<-LP.struct.test(W, m = 4 , n.iter = 50) ###extract p-value: h1.test$pval
##1.example: null case ##simulate a normal data with mean 0 and variance 1: X <-matrix(rnorm(500,mean=0,sd=1),20,25) ## Generate adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## test of structure: h0.test<-LP.struct.test(W, m = 4 , n.iter = 50) ###extract p-value: h0.test$pval ##2.example: two sample location alternative ##simulate a two sample locational difference normal data: X1<-matrix(rnorm(250,mean=0,sd=1),10,25) X2<-matrix(rnorm(250,mean=0.5,sd=1),10,25) X<-rbind(X1,X2) ## Generate adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## test of structure: h1.test<-LP.struct.test(W, m = 4 , n.iter = 50) ###extract p-value: h1.test$pval
This function provides nonparametric smooth approximation of the Laplacian graph spectra given a weighted-adjacency matrix .
LPSpectral(W, k, m=8,sparse=TRUE)
LPSpectral(W, k, m=8,sparse=TRUE)
W |
A |
k |
Number of approximated singular vectors and singular values to return, where |
m |
Number of LP-nonparametric basis used for approximation, where |
sparse |
Set to |
A list containing the following items:
LP |
|
Phi |
A |
sval |
A vector of length |
Mukhopadhyay, S. and Wang, K.
Mukhopadhyay, S. and Wang, K. (2018), "Graph Spectral Compression via Smoothing".
##1.toy example: ##simulate a two sample locational difference normal data: X1<-matrix(rnorm(250,mean=0,sd=1),10,25) X2<-matrix(rnorm(250,mean=0.5,sd=1),10,25) X<-rbind(X1,X2) ## Adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## Obtain top 10 approximated nontrivial singular values: data_sval<-LPSpectral(W, k=10)$sval ## Obtain approximated singular vector corresponding to the top nontrivial singular value: data_phi1<-LPSpectral(W, k=1)$Phi ## plot the results: par(mfrow=c(1,2)) plot(data_sval,type='b') plot(data_phi1) ##2.Senate Data ## Not run: data(senate) attach(senate) ##creating W (long computation) require(psych) W <- matrix(0,nrow(X),nrow(X)) for(i in 1:(nrow(X)-1)){ for(j in (i+1):nrow(X)) { W[i,j] <- psych::phi(table(X[i,],X[j,])) } } W = W + t(W) diag(W)<-0 ## Obtain top 10 approximated nontrivial singular values: senate_sval<-LPSpectral(W, k=10, m=15)$sval ## Obtain approximated singular vector corresponding to the top nontrivial singular value: senate_phi1<-LPSpectral(W, k=1, m=15)$Phi ## plot the results: par(mfrow=c(1,2)) plot(senate_sval,type='b') plot(senate_phi1) ## End(Not run)
##1.toy example: ##simulate a two sample locational difference normal data: X1<-matrix(rnorm(250,mean=0,sd=1),10,25) X2<-matrix(rnorm(250,mean=0.5,sd=1),10,25) X<-rbind(X1,X2) ## Adjacency matrix: dmat<-dist(X) W <-exp(-as.matrix(dmat)^2/(2*quantile(dmat,.5)^2)) ## Obtain top 10 approximated nontrivial singular values: data_sval<-LPSpectral(W, k=10)$sval ## Obtain approximated singular vector corresponding to the top nontrivial singular value: data_phi1<-LPSpectral(W, k=1)$Phi ## plot the results: par(mfrow=c(1,2)) plot(data_sval,type='b') plot(data_phi1) ##2.Senate Data ## Not run: data(senate) attach(senate) ##creating W (long computation) require(psych) W <- matrix(0,nrow(X),nrow(X)) for(i in 1:(nrow(X)-1)){ for(j in (i+1):nrow(X)) { W[i,j] <- psych::phi(table(X[i,],X[j,])) } } W = W + t(W) diag(W)<-0 ## Obtain top 10 approximated nontrivial singular values: senate_sval<-LPSpectral(W, k=10, m=15)$sval ## Obtain approximated singular vector corresponding to the top nontrivial singular value: senate_phi1<-LPSpectral(W, k=1, m=15)$Phi ## plot the results: par(mfrow=c(1,2)) plot(senate_sval,type='b') plot(senate_phi1) ## End(Not run)
The senate vote data contain 2508 observations ordered by time from 1989 to 2001, with a dimension of 100. The change point occurred on January 17th, 1995, at the beginning of the tenure of the 104th Congress when the Republican Party captured the US House of Representatives for the first time after 1956.
data("senate")
data("senate")
A list containing the following items:
year
:A vector of length 2508, time labels.
X
:A matrix of dimension 2508 by 100, original data of senate votes.
To generate the weighted adjacency matrix W
, one simple take the matrix X
and Compute:
Where
. And
.
See the examples in main function
LPSpectral
for the codes.
Roy, S., Atchade, Y., and Michailidis, G. (2017). "Change point estimation in high dimensional Markov random-field models". Journal of the Royal Statistical Society: Series B (Statistical Methodology), 79(4), 1187-1206.