Learn R Programming

PTAk (version 1.2-6)

PTA3: Principal Tensor Analysis on 3 modes

Description

Performs a truncated SVD-3modes analysis with or without specific metrics, penalised or not.

Usage

PTA3(X,nbPT=2,nbPT2=1,
                smoothing=FALSE,
                smoo=list(function(u)ksmooth(1:length(u),u,kernel="normal",
                          bandwidth=4,x.points=(1:length(u)))$y,
                          function(u)smooth.spline(u,df=3)$y,
                          NA),
                minpct=0.1,verbose=getOption("verbose"),file=NULL,
                modesnam=NULL,addedcomment="", ...)

Arguments

X
a tensor (as an array) of order 3, if non-identity metrics are used X is a list with data as the array and met a list of metrics
nbPT
a number specifying the number of 3modes Principal Tensors requested
nbPT2
if 0 no 2-modes solutions will be computed, 1 =all, >1 otherwise
smoothing
logical to consider smoothing or not
smoo
a list of length 3 with lists of functions operating on vectors component for the appropriate dimension (see details)
minpct
numerical 0-100 to control of computation of future solutions at this level and below
verbose
control printing
file
output printed at the prompt if NULL, or printed in the given file
modesnam
character vector of the names of the modes, if NULL "mo 1" ..."mo k"
addedcomment
character string printed after the title of the analysis
...
any other arguments passed to SVDGen or other functions

Value

Details

According to the decomposition described in Leibovici(1993) and Leibovici and Sabatier(1998) the function gives a generalisation of the SVD (2 modes) to 3 modes. It is the same algorithm used for PTAk but simpler as the recursivity implied by the k modes analysis is reduced only to one level i.e for every 3-modes Principal Tensors, 3 SVD are performed for every contracted product with one the three components of the 3-modes Principal Tensors (see APSOLU3, PTAk). Recent work from Tamara G Kolda showed on an example that orthogonal rank decompositions are not necesseraly nested. This makes PTA-3modes a model with nested decompositions not giving the exact orthogonal rank. So PTA-3modes will look for best approximation according to orthogonal tensors in a nested approximmation process. PTA3 decompositions is "a" generalisation of SVD but not the ... With the smoothing option smoo contain a list of (lists) of functions to apply on vectors of component (within the algorithm, see SVDgen). For a given dimension (1,2,or 3) a list of functions is given. If this list consists only of one function (no list needed) this function will be used at any level all the time : if one want to smooth only for the first Principal Tensor, put list(function,NA). Now you start to understand this list will have a maximum length of nbPT and the corresponding function will be used for the corresponding 3mode Principal Tensor. To smooth differently the associated solutions one have to put another level of nested lists otherwise the function given at the 3mode level will be used for all. These rules are te same for PTAk.

References

Leibovici D(1993) Facteurs Mesures Rptes et Analyses Factorielles : applications un suivi pidmiologique. Universit de Montpellier II. PhD Thesis in Mathmatiques et Applications (Biostatistiques).

Leibovici D and Sabatier R (1998) A Singular Value Decomposition of a k-ways array for a Principal Component Analysis of multi-way data, the PTA-k. Linear Algebra and its Applications, 269:307-329.

Kolda T.G (2003)A Counterexample to the Possibility of an Extension of the Eckart-Young Low-Rank Approximation Theorem for the Orthogonal Rank Tensor Decomposition. SIAM J. Matrix Analysis, 24(2):763-767, Jan. 2003.

See Also

SVDgen, FCAk, PTAk, summary.PTAk

Examples

Run this code
# example using Zone_climTUN dataset
 #  
# library(maptools)
# library(RColorBrewer)
# Yl=brewer.pal(11,"PuOr")
# data(Zone_climTUN)
## in fact a modified version of plot.Map was used
# plot(Zone_climTUN,ol=NA,auxvar=Zone_climTUN$att.data$PREC_OCTO)
##indicators 84 +3 to repeat
# Zone_clim<-Zone_climTUN$att.data[,c(2:13,15:26,28:39,42:53,57:80,83:95,55:56)]
# Zot <-Zone_clim[,85:87] ;temp <-colnames(Zot) 
# Zot <- as.matrix(Zot)%x%t(as.matrix(rep(1,12)))
# colnames(Zot) <-c(paste(rep(temp [1],12),1:12),paste(rep(temp [2],12),1:12), paste(rep(temp [3],12),1:12))
# Zone_clim <-cbind(Zone_clim[,1:84],Zot)
 
# Zone3w <- array(as.vector(as.matrix(Zone_clim)),c(2599,12,10))
## preprocessing
#Zone3w<-Multcent(dat=Zone3w,bi=NULL,by=3,centre=mean, centrebyBA=c(TRUE,FALSE),scalebyBA=c(TRUE,FALSE))
# Zone3w.PTA3<-PTA3(Zone3w,nbPT=3,nbPT2=3)
## summary and plot
# summary(Zone3w.PTA3)
#plot(Zone3w.PTA3,mod=c(2,3),nb1=1,nb2=11,lengthlabels=5,coefi=list(c(1,1,1),c(1,-1,-1)))
#plot(Zone_climTUN,ol=NA,auxvar=Zone3w.PTA3[[1]]$v[1,],nclass=30)
#plot(Zone_climTUN,ol=NA,auxvar=Zone3w.PTA3[[1]]$v[11,],nclass=30)
 
 ##############
 cat("A little fun using iris3 and matching randomly 15 for each iris sample!","")
 cat("then performing a PTA-3modes.  If many draws are done, plots")
 cat("show the stability of the first and third Principal Tensors.","")
 cat("iris3 is centered and reduced beforehand for each original variables.","")
#  demo function 
# source(paste(R.home(),"/library/PTAk/demo/PTA3.R",sep=""))
# demo.PTA3(bootn=10,show=5,openX11s=FALSE)

Run the code above in your browser using DataLab