LPGraph (version 2.1)

LPSpectral: Nonparametric smooth approximation of the Laplacian graph spectra

Description

This function provides nonparametric smooth approximation of the Laplacian graph spectra given a weighted-adjacency matrix \(W\).

Usage

LPSpectral(W, k, m=8,sparse=TRUE)

Arguments

W

A \(n\)-by-\(n\) weighted-adjacency matrix.

k

Number of approximated singular vectors and singular values to return, where \(k \leq m\).

m

Number of LP-nonparametric basis used for approximation, where \(m \leq n\). By default, \(m=8\).

sparse

Set to TRUE to make coefficients for LP basis sparse, thus allowing for further smoothing.

Value

A list containing the following items:

LP

\(m\)-by-\(m\) LP Spectral graph matrix.

Phi

A \(n\)-by-\(k\) matrix of LP-approximated singular vectors.

sval

A vector of length \(k\) containing top k approximated singular values.

References

Mukhopadhyay, S. and Wang, K. (2018), "Graph Spectral Compression via Smoothing".

Examples

Run this code
# 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)
  
# }

Run the code above in your browser using DataCamp Workspace