# 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='')
   
# }
Run the code above in your browser using DataLab