LPSpectral: Nonparametric smooth approximation of the Laplacian graph...

Description Usage Arguments Value Author(s) References Examples

View source: R/LPSpectral.R

Description

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

Usage

1
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 ≤q m.

m

Number of LP-nonparametric basis used for approximation, where m ≤q 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.

Author(s)

Mukhopadhyay, S. and Wang, K.

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
   ##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)

LPGraph documentation built on Jan. 31, 2020, 1:06 a.m.