Title: | Three-Way Component Analysis |
---|---|
Description: | Component analysis for three-way data arrays by means of Candecomp/Parafac, Tucker3, Tucker2 and Tucker1 models. |
Authors: | Maria Antonietta Del Ferraro, Henk A.L. Kiers, Paolo Giordani |
Maintainer: | Paolo Giordani <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.3 |
Built: | 2024-11-10 06:25:01 UTC |
Source: | CRAN |
Produces percentile intervals for all output parameters. The percentile intervals indicate the instability of the sample solutions.
bootstrapCP(X, A, B, C, n, m, p, r, ort1, ort2, ort3, conv, centopt, normopt, scaleopt, maxit, laba, labb, labc)
bootstrapCP(X, A, B, C, n, m, p, r, ort1, ort2, ort3, conv, centopt, normopt, scaleopt, maxit, laba, labb, labc)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
n |
Number of |
m |
Number of |
p |
Number of |
r |
Number of extracted components |
ort1 |
Type of constraints on |
ort2 |
Type of constraints on |
ort3 |
Type of constraints on |
conv |
Convergence criterion |
centopt |
Centering option (see |
normopt |
Normalization option (see |
scaleopt |
Scaling option (see |
maxit |
Maximal number of iterations |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
Bint |
Bootstrap percentile interval of every element of |
Cint |
Bootstrap percentile interval of every element of |
fpint |
Bootstrap percentile interval for the goodness of fit index expressed as a percentage |
The preprocessing must be done in same way as for sample analysis.
The resampling mode must be the A
-mode.
The starting points for every bootstrap solution are two: rational (using SVD) and solution from the observed sample.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2004). Bootstrap confidence intervals for three-way methods. Journal of Chemometrics 18:22–36.
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # CP solution TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) ## Not run: # Bootstrap analysis on CP solution boot <- bootstrapCP(TVdata, TVcp$A, TVcp$B, TVcp$C, 30, 16, 15, 2, 1, 1, 1, 1e-6, 0, 0, 0, 10000, labSTUDENT, labSCALE, labPROGRAM) # Bootstrap analysis on CP solution (when labels are not available) boot <- bootstrapCP(TVdata, TVcp$A, TVcp$B, TVcp$C, 30, 16, 15, 2, 1, 1, 1, 1e-6, 0, 0, 0, 10000) ## End(Not run)
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # CP solution TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) ## Not run: # Bootstrap analysis on CP solution boot <- bootstrapCP(TVdata, TVcp$A, TVcp$B, TVcp$C, 30, 16, 15, 2, 1, 1, 1, 1e-6, 0, 0, 0, 10000, labSTUDENT, labSCALE, labPROGRAM) # Bootstrap analysis on CP solution (when labels are not available) boot <- bootstrapCP(TVdata, TVcp$A, TVcp$B, TVcp$C, 30, 16, 15, 2, 1, 1, 1, 1e-6, 0, 0, 0, 10000) ## End(Not run)
Produces percentile intervals for all output parameters. The percentile intervals indicate the instability of the sample solutions.
bootstrapT3(X, A, B, C, G, n, m, p, r1, r2, r3, conv, centopt, normopt, optimalmatch, laba, labb, labc)
bootstrapT3(X, A, B, C, G, n, m, p, r1, r2, r3, conv, centopt, normopt, optimalmatch, laba, labb, labc)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
G |
Matricized core array (frontal slices) |
n |
Number of |
m |
Number of |
p |
Number of |
r1 |
Number of extracted components for the |
r2 |
Number of extracted components for the |
r3 |
Number of extracted components for the |
conv |
Convergence criterion |
centopt |
Centering option (see |
normopt |
Normalization option (see |
optimalmatch |
Binary indicator (0 if the procedure uses matching via orthogonal rotation towards full solutions, 1 if the procedure uses matching via optimal transformation towards full solutions) |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
Bint |
Bootstrap percentile interval of every element of |
Cint |
Bootstrap percentile interval of every element of |
Gint |
Bootstrap percentile interval of matricized core array (frontal slices) |
fpint |
Bootstrap percentile interval for the goodness of fit index expressed as a percentage |
The preprocessing must be done in same way as for sample analysis.
The resampling mode must be the A
-mode.
The starting points for every bootstrap solution are two: rational (using SVD) and solution from the observed sample.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2004). Bootstrap confidence intervals for three-way methods. Journal of Chemometrics 18:22–36.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) ## Not run: # Bootstrap analysis on T3 solution using matching via optimal transformation boot <- bootstrapT3(Bus, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 7, 5, 37, 2, 2, 2, 1e-6, 0, 0, 1, laba, labb, labc) # Bootstrap analysis on T3 solution using matching via orthogonal rotation # (when labels are not available) boot <- bootstrapT3(Bus, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 7, 5, 37, 2, 2, 2, 1e-6, 0, 0, 0) ## End(Not run)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) ## Not run: # Bootstrap analysis on T3 solution using matching via optimal transformation boot <- bootstrapT3(Bus, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 7, 5, 37, 2, 2, 2, 1e-6, 0, 0, 1, laba, labb, labc) # Bootstrap analysis on T3 solution using matching via orthogonal rotation # (when labels are not available) boot <- bootstrapT3(Bus, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 7, 5, 37, 2, 2, 2, 1e-6, 0, 0, 0) ## End(Not run)
Three-way data about the process of learning to read of seven first-grade children tested weekly (from week 3 to 47, but weeks 10, 19, 20, 29, 35, 36, 39, 43 were holidays and, thus, data on 37 weeks) with five different tests.
data(Bus)
data(Bus)
A matrix with 7 rows and 185 (5x37) columns.
The rows refer to the pupils.
The columns refer to the combinations of tests and weeks with the tests nested within the weeks.
The matrix contains the frontal slices next to each other of the original array.
The meanings and the ranges of the tests are as follows:
L
: letter knowledge test (scores in 0-47);
P
: regular orthographic short words (scores in 0-10);
Q
: regular orthographic long words (scores in 0-10);
S
: regular orthographic long and short words within context (scores in 0-15);
R
: irregular orthographic long and short words (scores in 0-15).
In the literature the Bus data have been analyzed by Tucker3 (see Kroonenberg, 1983; Timmerman, 2001). There is consensus on normalizing the data so to eliminate artificial differences among ranges of tests. Different centering options and numbers of extracted components have been chosen. Specifically, Kroonenberg (1983) suggests averaging over pupils and tests for each time occasions and extracting two components for every mode. Timmerman (2001) suggests to apply Tucker3 to the normalized data with two components for pupils and time occasions and one component for tests.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P.M. Kroonenberg (1983). Three-mode Principal Component Analysis. Theory and Applications. DSWO Press, Leiden.
M.E. Timmerman (2001). Component Analysis of Multisubject Multivariate Longitudinal Data. Ph.D. Thesis, University of Groningen.
Computation of a columnwise centered version of a matrix.
Cc(A)
Cc(A)
A |
Matrix of any order |
Ac |
Matrix columnwise centered |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(6*3),ncol=3) Y <- Cc(X) apply(Y,2,mean)
X <- matrix(rnorm(6*3),ncol=3) Y <- Cc(X) apply(Y,2,mean)
Concatenates the columns of two matrices next to each other.
ccmat(A, B)
ccmat(A, B)
A |
Matrix of the same order of |
B |
Matrix of the same order of |
mat |
Matrix in which the columns of |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(6*3),ncol=3) Y <- matrix(rnorm(6*3),ncol=3) Z <- ccmat(X,Y)
X <- matrix(rnorm(6*3),ncol=3) Y <- matrix(rnorm(6*3),ncol=3) Z <- ccmat(X,Y)
Centering of a matricized array across one mode (modes indicated by 1,2, or 3).
cent3(X, n, m, p, mode)
cent3(X, n, m, p, mode)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
mode |
Centering option (1 if |
Y |
Matrix of order ( |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
X <- array(c(rnorm(120)),c(6,5,4)) # matricized array Y <- supermat(X) # data centered across A-mode Z <- cent3(Y$Xa, 6, 5, 4, 1) apply(Z,2,mean) # data centered also across B-modes (double centering) Z <- cent3(Z, 6, 5, 4, 2) apply(Z,1,mean) apply(Z,2,mean)
X <- array(c(rnorm(120)),c(6,5,4)) # matricized array Y <- supermat(X) # data centered across A-mode Z <- cent3(Y$Xa, 6, 5, 4, 1) apply(Z,2,mean) # data centered also across B-modes (double centering) Z <- cent3(Z, 6, 5, 4, 2) apply(Z,1,mean) apply(Z,2,mean)
Detects the underlying structure of a three-way array according to the Candecomp/Parafac (CP) model.
CP(data,laba,labb,labc)
CP(data,laba,labb,labc)
data |
Array of order |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
fit |
Fit value expressed as a percentage |
tripcos |
Matrix of the triple cosines among pairs of components (to inspect degeneracy) |
fitValues |
Fit values expressed as a percentage upon convergence for all the runs of the CP algorithm (see |
funcValues |
Function values upon convergence for all the runs of the CP algorithm (see |
cputime |
Computation times for all the runs of the CP algorithm (see |
iter |
Numbers of iterations upon convergence for all the runs of the CP algorithm (see |
fitA |
Fit contributions for the |
fitB |
Fit contributions for the |
fitC |
Fit contributions for the |
Bint |
Bootstrap percentile interval of every element of |
Cint |
Bootstrap percentile interval of every element of |
fpint |
Bootstrap percentile interval for the goodness of fit index expressed as a percentage (see |
Afull |
Component matrix for the |
As1 |
Component matrix for the |
As2 |
Component matrix for the |
Bfull |
Component matrix for the |
Bs1 |
Component matrix for the |
Bs2 |
Component matrix for the |
Cfull |
Component matrix for the |
Cs1 |
Component matrix for the |
Cs2 |
Component matrix for the |
A1 |
Component matrix for the |
B1 |
Component matrix for the |
C1 |
Component matrix for the |
A2 |
Component matrix for the |
B2 |
Component matrix for the |
C2 |
Component matrix for the |
laba |
Vector of length |
labb |
Vector of length |
labc |
Vector of length |
Xprep |
Matrix of order ( |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
J.D. Carroll and J.J. Chang (1970). Analysis of individual differences in multidimensional scaling via an N-way generalization of 'Eckart-Young' decomposition. Psychometrika 35:283–319.
P. Giordani, H.A.L. Kiers, M.A. Del Ferraro (2014). Three-way component analysis using the R package ThreeWay. Journal of Statistical Software 57(7):1–23. http://www.jstatsoft.org/v57/i07/.
R.A. Harshman (1970). Foundations of the Parafac procedure: models and conditions for an 'explanatory' multi-mode factor analysis. UCLA Working Papers in Phonetics 16:1–84.
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) ## Not run: # interactive CP analysis TVcp <- CP(TVdata, labSTUDENT, labSCALE, labPROGRAM) # interactive CP analysis (when labels are not available) TVcp <- CP(TVdata) ## End(Not run)
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) ## Not run: # interactive CP analysis TVcp <- CP(TVdata, labSTUDENT, labSCALE, labPROGRAM) # interactive CP analysis (when labels are not available) TVcp <- CP(TVdata) ## End(Not run)
Plots fits against numbers of dimensions, with S
as labels and fits against number of effective paramaters.
CPdimensionalityplot(A, n, m, p)
CPdimensionalityplot(A, n, m, p)
A |
A matrix with columns: number of components, goodness of fit (%) |
n |
Number of |
m |
Number of |
p |
Number of |
A
is usually the first and fourth columns of the output of DimSelector
.
The number of effective parameters in a Candecomp/Parafac analysis is discussed in Weesie and Van Houwelingen (1983).
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
E. Ceulemans \& H.A.L. Kiers (2006). Selecting among three-mode principal component models of different types and complexities: A numerical convex hull based method. British Journal of Mathematical and Statistical Psychology 59:133–150.
J. Weesie \& H. Van Houwelingen (1983). GEPCAM users' manual (first draft). Utrecht, The Netherlands: Institute of Mathematical Statistics, State University of Utrecht.
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # Fit values of CP with different numbers of components (from 1 to 5) FitCP <- CPrunsFit(TVdata, 30, 16, 15, 5) OutCP <- FitCP[,c(1,4)] CPdimensionalityplot(OutCP, 30, 16, 15)
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # Fit values of CP with different numbers of components (from 1 to 5) FitCP <- CPrunsFit(TVdata, 30, 16, 15, 5) OutCP <- FitCP[,c(1,4)] CPdimensionalityplot(OutCP, 30, 16, 15)
Computation of fit contributions.
CPfitpartitioning(Xprep, n, m, p, A, B, C, laba, labb, labc)
CPfitpartitioning(Xprep, n, m, p, A, B, C, laba, labb, labc)
Xprep |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
fitA |
Fit contribution for the |
fitB |
Fit contribution for the |
fitC |
Fit contribution for the |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # CP solution TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # Fitpartitioning of the CP solution FitCP <- CPfitpartitioning(TVdata, 30, 16, 15, TVcp$A, TVcp$B, TVcp$C, labSTUDENT, labSCALE, labPROGRAM) # Fitpartitioning of the CP solution (when labels are not available) FitCP <- CPfitpartitioning(TVdata, 30, 16, 15, TVcp$A, TVcp$B, TVcp$C)
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # CP solution TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # Fitpartitioning of the CP solution FitCP <- CPfitpartitioning(TVdata, 30, 16, 15, TVcp$A, TVcp$B, TVcp$C, labSTUDENT, labSCALE, labPROGRAM) # Fitpartitioning of the CP solution (when labels are not available) FitCP <- CPfitpartitioning(TVdata, 30, 16, 15, TVcp$A, TVcp$B, TVcp$C)
Alternating Least Squares algorithm for the minimization of the Candecomp/Parafac loss function.
CPfunc(X, n, m, p, r, ort1, ort2, ort3, start, conv, maxit, A, B, C)
CPfunc(X, n, m, p, r, ort1, ort2, ort3, start, conv, maxit, A, B, C)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r |
Number of extracted components |
ort1 |
Type of constraints on |
ort2 |
Type of constraints on |
ort3 |
Type of constraints on |
start |
Starting point (0 for starting point of the algorithm from SVD's, 1 for random starting point (orthonormalized component matrices), 2 for user specified components |
conv |
Convergence criterion |
maxit |
Maximal number of iterations |
A |
Optional (necessary if start=2) starting value for |
B |
Optional (necessary if start=2) starting value for |
C |
Optional (necessary if start=2) starting value for |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
f |
Loss function value |
fp |
Fit value expressed as a percentage |
iter |
Number of iterations |
tripcos |
Minimal triple cosine between two components across three component matrices (to inspect degeneracy) |
mintripcos |
Minimal triple cosine during the iterative algorithm observed at every 10 iterations (to inspect degeneracy) |
ftiter |
Matrix containing in each row the function value and the minimal triple cosine at every 10 iterations |
cputime |
Computation time |
The loss function to be minimized is , where
is a diagonal matrix holding the
k
-th row of C
.
CPfunc
is the same as CPfuncrep
except that all printings are available.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
R.A. Harshman (1970). Foundations of the Parafac procedure: models and conditions for an ‘explanatory’ multi-mode factor analysis. UCLA Working Papers in Phonetics 16:1–84.
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # unconstrained CP solution using two components # (rational starting point by SVD [start=0]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix (rational starting point by SVD [start=0]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 2, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix and zero correlated C-mode component matrix # (rational starting point by SVD [start=0]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 2, 1, 3, 0, 1e-6, 10000) # unconstrained CP solution using two components # (random orthonormalized starting point [start=1]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 1, 1, 1, 1, 1e-6, 10000) # unconstrained CP solution using two components (user starting point [start=2]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 1, 1, 1, 2, 1e-6, 10000, matrix(rnorm(30*2),nrow=30), matrix(rnorm(16*2),nrow=16), matrix(rnorm(15*2),nrow=15))
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # unconstrained CP solution using two components # (rational starting point by SVD [start=0]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix (rational starting point by SVD [start=0]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 2, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix and zero correlated C-mode component matrix # (rational starting point by SVD [start=0]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 2, 1, 3, 0, 1e-6, 10000) # unconstrained CP solution using two components # (random orthonormalized starting point [start=1]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 1, 1, 1, 1, 1e-6, 10000) # unconstrained CP solution using two components (user starting point [start=2]) TVcp <- CPfunc(TVdata, 30, 16, 15, 2, 1, 1, 1, 2, 1e-6, 10000, matrix(rnorm(30*2),nrow=30), matrix(rnorm(16*2),nrow=16), matrix(rnorm(15*2),nrow=15))
Alternating Least Squares algorithm for the minimization of the Candecomp/Parafac loss function.
CPfuncrep(X, n, m, p, r, ort1, ort2, ort3, start, conv, maxit, A, B, C)
CPfuncrep(X, n, m, p, r, ort1, ort2, ort3, start, conv, maxit, A, B, C)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r |
Number of extracted components |
ort1 |
Type of constraints on |
ort2 |
Type of constraints on |
ort3 |
Type of constraints on |
start |
Starting point (0 for starting point of the algorithm from SVD's, 1 for random starting point (orthonormalized component matrices), 2 for user specified components |
conv |
Convergence criterion |
maxit |
Maximal number of iterations |
A |
Optional (necessary if start=2) starting value for |
B |
Optional (necessary if start=2) starting value for |
C |
Optional (necessary if start=2) starting value for |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
f |
Loss function value |
fp |
Fit value expressed as a percentage |
iter |
Number of iterations |
tripcos |
Minimal triple cosine between two components across three component matrices (to inspect degeneracy) |
mintripcos |
Minimal triple cosine during the iterative algorithm observed at every 10 iterations (to inspect degeneracy) |
ftiter |
Matrix containing in each row the function value and the minimal triple cosine at every 10 iterations |
cputime |
Computation time |
The loss function to be minimized is , where
is a diagonal matrix holding the
k
-th row of C
.
CPfuncrep
is the same as CPfunc
except that all printings are suppressed. Thus, CPfuncrep
can be helpful for simulation experiments.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
R.A. Harshman (1970). Foundations of the Parafac procedure: models and conditions for an ‘explanatory’ multi-mode factor analysis. UCLA Working Papers in Phonetics 16:1–84.
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # unconstrained CP solution using two components # (rational starting point by SVD [start=0]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix (rational starting point by SVD [start=0]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 2, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix and zero correlated C-mode component matrix # (rational starting point by SVD [start=0]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 2, 1, 3, 0, 1e-6, 10000) # unconstrained CP solution using two components # (random orthonormalized starting point [start=1]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 1, 1e-6, 10000) # unconstrained CP solution using two components (user starting point [start=2]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 2, 1e-6, 10000, matrix(rnorm(30*2),nrow=30), matrix(rnorm(16*2),nrow=16), matrix(rnorm(15*2),nrow=15))
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # unconstrained CP solution using two components # (rational starting point by SVD [start=0]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix (rational starting point by SVD [start=0]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 2, 1, 1, 0, 1e-6, 10000) # constrained CP solution using two components with orthogonal A-mode # component matrix and zero correlated C-mode component matrix # (rational starting point by SVD [start=0]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 2, 1, 3, 0, 1e-6, 10000) # unconstrained CP solution using two components # (random orthonormalized starting point [start=1]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 1, 1e-6, 10000) # unconstrained CP solution using two components (user starting point [start=2]) TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 2, 1e-6, 10000, matrix(rnorm(30*2),nrow=30), matrix(rnorm(16*2),nrow=16), matrix(rnorm(15*2),nrow=15))
Computes all the Candecomp/Parafac solutions (CP) with r
(from 1 to maxC
) components.
CPrunsFit(X, n, m, p, maxC)
CPrunsFit(X, n, m, p, maxC)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
maxC |
Maximum dimensionality for the |
out |
Matrix with columns: number of components for the |
The structure of out
is consistent with Tucker models. In CP, the first and forth columns are sufficient for choosing the optimal number of components.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56:449–470.
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # Fit values of CP with different numbers of components (from 1 to 5) FitCP <- CPrunsFit(TVdata, 30, 16, 15, 5)
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # Fit values of CP with different numbers of components (from 1 to 5) FitCP <- CPrunsFit(TVdata, 30, 16, 15, 5)
Selects among three-mode principal component models of different complexities.
DimSelector(out, n, m, p, model)
DimSelector(out, n, m, p, model)
out |
Matrix with columns: number of components for the |
n |
Number of |
m |
Number of |
p |
Number of |
model |
Kind of model (1 for Candecomp/Parafac, 2 for Tucke3, 3 for Tucker2, 4 for Tucker1 |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
E. Ceulemans and H.A.L. Kiers (2006). Selecting among three-mode principal component models of different types and complexities: A numerical convex hull based method. British Journal of Mathematical and Statistical Psychology 59:133–150.
J. Weesie and H. Van Houwelingen (1983). GEPCAM users' manual (first draft). Utrecht, The Netherlands: Institute of Mathematical Statistics, State University of Utrecht.
LineCon
, T3runsApproxFit
T2runsApproxFit
T1runsFit
CPrunsFit
data(Bus) # Analysis on T3 with different numbers of components (from 1 to 4 for the A-mode, # from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT3 <- T3runsApproxFit(Bus,7,5,37,4,4,4) T3opt <- DimSelector(FitT3,7,5,37,2)
data(Bus) # Analysis on T3 with different numbers of components (from 1 to 4 for the A-mode, # from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT3 <- T3runsApproxFit(Bus,7,5,37,4,4,4) T3opt <- DimSelector(FitT3,7,5,37,2)
Program for producing jointplots in general.
jointplotgen(K, A, B, C, fixmode, fixunit, laba, labb, labc)
jointplotgen(K, A, B, C, fixmode, fixunit, laba, labb, labc)
K |
Matricized core array (frontal slices) |
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
fixmode |
Mode for which one unit is to be chosen (1 for A-mode, 2 for B-mode, 3 for C-mode) |
fixunit |
Number of component for which joint plot is desired |
laba |
Vector of length |
labb |
Vector of length |
labc |
Vector of length |
fit |
Percentage of info for component at hand, explained by two-dimensional plot |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # <- T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # Joint plot for mode C and component 2 jointplotgen(BusT3$H, BusT3$A, BusT3$B, BusT3$C, 3, 2, laba, labb, labc)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # <- T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # Joint plot for mode C and component 2 jointplotgen(BusT3$H, BusT3$A, BusT3$B, BusT3$C, 3, 2, laba, labb, labc)
Three-way proximity data about 15 kinship terms produced by 6 groups of subjects.
data(Kinship)
data(Kinship)
An array of order 15 x 15 x 6.
The A-mode and B-mode entities are the kinship terms (Aunt, Brother, Cousin, Daughter, Father, Granddaughter, Grandfather, Grandmother, Grandson, Mother, Nephew, Niece, Sister, Son, Uncle).
The C-mode entities are groups of subjects (First female, Second female, First male, Second male, Single female, Single male).
The original data have been introduced by Rosenborg \& Kim (1975). The data were collected by asking to 6 groups of subjects to produce a partition of 15 kinship terms. Two groups (Single female and Single male) were composed by 85 male and 85 female college students, respectively, and provided a single partition. Two additional groups of, respectively, 80 male and 80 female students produced two partitions each (First female, Second female, First male, Second male). In fact, they were informed in advance that, after making the first partition, they should give a new partition of the kinship terms using a different basis of meaning. The array contains similarities. For every group of subjects, the numbers of times in which the kinship terms were grouped together are given.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
S. Rosenborg \& M.P. Kim (1975). The method of sorting as a data-gathering procedure in multivariate research. Multivariate Behavioral Research 10:489–502.
data(Kinship) ## The labels are in the data array laba <- dimnames(Kinship)[[1]] labb <- dimnames(Kinship)[[2]] labc <- dimnames(Kinship)[[3]] ## Candecomp/Parafac analysis ## Not run: CP(Kinship,laba,labb,labc) ## End(Not run)
data(Kinship) ## The labels are in the data array laba <- dimnames(Kinship)[[1]] labb <- dimnames(Kinship)[[2]] labc <- dimnames(Kinship)[[3]] ## Candecomp/Parafac analysis ## Not run: CP(Kinship,laba,labb,labc) ## End(Not run)
Checks whether the middle point is located below or on the line connecting its neighbors.
LineCon(f1, f2, f3, fp1, fp2, fp3)
LineCon(f1, f2, f3, fp1, fp2, fp3)
f1 |
Goodness-of-fit value for the first point |
f2 |
Goodness-of-fit value for the second point |
f3 |
Goodness-of-fit value for the third point |
fp1 |
Number of effective parameters for the first point |
fp2 |
Number of effective parameters for the second point |
fp3 |
Number of effective parameters for the third point |
ret |
Value that indicates if the middle point is located below or on the line connecting its neighbors (0 if the middle point is not located below the line connecting its neighbors, 1 if the middle point is not located on the line connecting its neighbors) |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
E. Ceulemans and H.A.L. Kiers (2006). Selecting among three-mode principal component models of different types and complexities: A numerical convex hull based method. British Journal of Mathematical and Statistical Psychology 59:133–150.
J. Weesie and H. Van Houwelingen (1983). GEPCAM users' manual (first draft). Utrecht, The Netherlands: Institute of Mathematical Statistics, State University of Utrecht.
data(Bus) # T2-AB with 1 component for the A- and B-mode FitBusT2AB11 <- T2funcrep(Bus, 7, 5, 37, 1, 1, 37, 0, 1e-6,1)$fp # T2-AB with 2 components for the A-mode and 1 component for the B-mode FitBusT2AB21 <- T2funcrep(Bus, 7, 5, 37, 2, 1, 37, 0, 1e-6, 1)$fp # T2-AB with 1 component for the A-mode and 2 components for the B-mode # T2-AB with 1 component for the A-mode and 2 components for the B-mode # FitBusT2AB21>FitBusT2AB12 # T2-AB with 2 components for the A- and B-mode FitBusT2AB22 <- T2funcrep(Bus, 7, 5, 37, 2, 2, 37, 0, 1e-6,1)$fp # number of effective parameters n x r1 + m x r2 + r1 x r2 x p - r1^2 - r2^2 nepT2AB11 <- 47 nepT2AB21 <- 88 nepT2AB22 <- 164 ret <- LineCon(FitBusT2AB11, FitBusT2AB21, FitBusT2AB22, nepT2AB11, nepT2AB21, nepT2AB22)
data(Bus) # T2-AB with 1 component for the A- and B-mode FitBusT2AB11 <- T2funcrep(Bus, 7, 5, 37, 1, 1, 37, 0, 1e-6,1)$fp # T2-AB with 2 components for the A-mode and 1 component for the B-mode FitBusT2AB21 <- T2funcrep(Bus, 7, 5, 37, 2, 1, 37, 0, 1e-6, 1)$fp # T2-AB with 1 component for the A-mode and 2 components for the B-mode # T2-AB with 1 component for the A-mode and 2 components for the B-mode # FitBusT2AB21>FitBusT2AB12 # T2-AB with 2 components for the A- and B-mode FitBusT2AB22 <- T2funcrep(Bus, 7, 5, 37, 2, 2, 37, 0, 1e-6,1)$fp # number of effective parameters n x r1 + m x r2 + r1 x r2 x p - r1^2 - r2^2 nepT2AB11 <- 47 nepT2AB21 <- 88 nepT2AB22 <- 164 ret <- LineCon(FitBusT2AB11, FitBusT2AB21, FitBusT2AB22, nepT2AB11, nepT2AB21, nepT2AB22)
Three-way data about six sampling sites along a small French stream (the Meaudret) on which ten biological and chemical variables are collected four times.
data(meaudret)
data(meaudret)
An array of order 6 x 10 x 4.
The A-mode entities are sampling sites (Site1, ..., Site6).
The B-mode entities are biological and chemical variables (Temp, Debi, PH, Cond, Oxyg, Biod, Chem, NH4, NO3, PO4).
The C-mode entities are months (June, August, November, February).
The ranges of the variables are very different and, therefore, normalization of the raw data is recommended. The data have been used by Kiers (1991) in order to show the existing relations among three-way methods.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56:449–470.
data(meaudret) ## The labels are in the data array laba <- dimnames(meaudret)[[1]] labb <- dimnames(meaudret)[[2]] labc <- dimnames(meaudret)[[3]] ## Candecomp/Parafac analysis ## Not run: CP(meaudret,laba,labb,labc) ## Tucker3 analysis T3(meaudret,laba,labb,labc) ## Tucker2 analysis T2(meaudret,laba,labb,labc) ## Tucker1 analysis T1(meaudret,laba,labb,labc) ## End(Not run)
data(meaudret) ## The labels are in the data array laba <- dimnames(meaudret)[[1]] labb <- dimnames(meaudret)[[2]] labc <- dimnames(meaudret)[[3]] ## Candecomp/Parafac analysis ## Not run: CP(meaudret,laba,labb,labc) ## Tucker3 analysis T3(meaudret,laba,labb,labc) ## Tucker2 analysis T2(meaudret,laba,labb,labc) ## Tucker1 analysis T1(meaudret,laba,labb,labc) ## End(Not run)
Normalization of a matricized array within one mode (modes indicated by 1,2, or 3) to sum of squares equal to product of size of other modes.
norm3(X, n, m, p, mode)
norm3(X, n, m, p, mode)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
mode |
Normalization option (1 if |
Y |
Matrix of order ( |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
X <- array(c(rnorm(120)), c(6,5,4)) # matricized array Y <- supermat(X) # data normalized within A-mode Z <- norm3(Y$Xa, 6, 5, 4, 1) apply(Z^2,1,sum) # data normalized within C-mode Z <- norm3(Y$Xa, 6, 5, 4, 3) Z <- permnew(Z, 6, 5, 4) Z <- permnew(Z, 5, 4, 6) apply(Z^2, 1, sum)
X <- array(c(rnorm(120)), c(6,5,4)) # matricized array Y <- supermat(X) # data normalized within A-mode Z <- norm3(Y$Xa, 6, 5, 4, 1) apply(Z^2,1,sum) # data normalized within C-mode Z <- norm3(Y$Xa, 6, 5, 4, 3) Z <- permnew(Z, 6, 5, 4) Z <- permnew(Z, 5, 4, 6) apply(Z^2, 1, sum)
Produces normalized varimax rotated version of A
and rotation matrix T
.
normvari(A)
normvari(A)
A |
Matrix to be to be rotated |
A list including the following components:
B |
Rotated version of |
T |
Rotation matrix |
f |
Varimax function value |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H. Kaiser (1958). The varimax criterion for analytic rotation in factor analysis. Psychometrika 23:187–200.
X <- matrix(rnorm(6*3),ncol=3) Y <- normvari(X) # normalized varimax rotated version of X Y$B # rotation matrix Y$T
X <- matrix(rnorm(6*3),ncol=3) Y <- normvari(X) # normalized varimax rotated version of X Y$B # rotation matrix Y$T
Computation of a columnwise normalized version of a matrix.
nrm2(A)
nrm2(A)
A |
Matrix of any order |
N |
Matrix columnwise normalized |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(6*3),ncol=3) Y <- nrm2(X) apply(Y^2, 2, sum)
X <- matrix(rnorm(6*3),ncol=3) Y <- nrm2(X) apply(Y^2, 2, sum)
In case of vectors, an ordering of its elements in ascending order is produced; in case of matrices, the ordering in ascending order refers to every column.
ord(X)
ord(X)
X |
Vector or matrix to be ordered |
A |
Vector or matrix with the elements sorted in ascending order |
a |
Vector or matrix with the ordering indices |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
# vector x <- rnorm(6) y <- ord(x) # matrix X <- matrix(rnorm(6*3),ncol=3) Y <- ord(X)
# vector x <- rnorm(6) y <- ord(x) # matrix X <- matrix(rnorm(6*3),ncol=3) Y <- ord(X)
Returns an orthonormal basis for the range of A
.
orth(A)
orth(A)
A |
Matrix to be orthogonalized |
Q |
Orthonormal basis for the range of |
The columns of Q
span the same space as the columns of A
with t(Q)Q=I
.
The number of columns of Q
is the rank of A
.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(6*3),ncol=3) Y <- orth(X)
X <- matrix(rnorm(6*3),ncol=3) Y <- orth(X)
Produces a simultaneous orthomax rotation of two matrices (using one rotation matrix).
orthmax2(A1, A2, gam1, gam2, conv)
orthmax2(A1, A2, gam1, gam2, conv)
A1 |
First matrix to be rotated with the same number of columns of A2 |
A2 |
Second matrix to be rotated with the same number of columns of A1 |
gam1 |
orthmax parameter for |
gam2 |
orthmax parameter for |
conv |
Optional convergence value (default 1e-6) |
A list including the following components:
B1 |
Rotated version of |
B2 |
Rotated version of |
T |
Rotation matrix |
f |
Orthomax function value |
The function to be maximized is .
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
R. Jennrich (1970). Orthogonal rotation algorithms. Psychometrika 35:229–235.
X <- matrix(rnorm(8*3),ncol=3) Y <- matrix(rnorm(6*3),ncol=3) orthXY <- orthmax2(X,Y,1,2) # rotated version of X orthXY$B1 # rotated version of Y orthXY$B2 # rotation matrix orthXY$T
X <- matrix(rnorm(8*3),ncol=3) Y <- matrix(rnorm(6*3),ncol=3) orthXY <- orthmax2(X,Y,1,2) # rotated version of X orthXY$B1 # rotated version of Y orthXY$B2 # rotation matrix orthXY$T
Performs Principal Component Analysis (PCA) of the mean matrix aggregated over mode number indicated by aggregmode
.
pcamean(X, n, m, p, laba, labb, labc)
pcamean(X, n, m, p, laba, labb, labc)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
Y |
An object of class |
ev |
A vector containing the eigenvalues of |
A1 |
Component matrix for the |
B1 |
Component matrix for the |
C1 |
Component matrix for the |
A2 |
Component matrix for the |
B2 |
Component matrix for the |
C2 |
Component matrix for the |
aggregmode
denotes the mode over which means are computed (1 for A
-mode, 2 for B
-mode, 3 for C
-mode).
aggregmode
is provided interactively.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H. Kaiser (1958). The varimax criterion for analytic rotation in factor analysis. Psychometrika 23:187–200.
C. Harris \& H. Kaiser (1964). Some mathematical notes on three-mode factor analysis. Psychometrika 29:347–362.
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) ## Not run: # PCA on the mean matrix TVpcamean <- pcamean(TVdata, 30, 16, 15, labSTUDENT, labSCALE, labPROGRAM) # PCA on the mean matrix (when labels are not available) TVpcamean <- pcamean(TVdata, 30, 16, 15) ## End(Not run)
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) ## Not run: # PCA on the mean matrix TVpcamean <- pcamean(TVdata, 30, 16, 15, labSTUDENT, labSCALE, labPROGRAM) # PCA on the mean matrix (when labels are not available) TVpcamean <- pcamean(TVdata, 30, 16, 15) ## End(Not run)
Computes PCASup analysis for the direction concerning the reduced mode.
pcasup1(X, n, m, p, model)
pcasup1(X, n, m, p, model)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
model |
Tucker1 model choice (1 for T1-A, 2 for T1-B, 3 for T2-C) |
A list including the following components:
A |
Matrix of the eingenvectors of the supermatrix containing the frontal slices of the array ( |
B |
Matrix of the eingenvectors of the supermatrix containing the horizontal slices of the array ( |
C |
Matrix of the eingenvectors of the supermatrix containing the lateral slices of the array ( |
la |
Vector of the eigenvalues of the supermatrix containing the frontal slices of the array ( |
lb |
Vector of the eigenvalues of the supermatrix containing the horizontal slices of the array ( |
lc |
Vector of the eigenvalues of the supermatrix containing the lateral slices of the array ( |
pcasup1
computes the Tucker1 solution.
Cumulative sum of eigenvalues and fits from PCAsup applied to the reduced mode are automatically printed.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56: 449–470.
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
L.R Tucker (1966). Some mathematical notes on three-mode factor analysis. Psychometrika 31: 279–311.
data(Bus) # PCA-sup for T1-B pcasupBus <- pcasup1(Bus, 7, 5, 37, 2)
data(Bus) # PCA-sup for T1-B pcasupBus <- pcasup1(Bus, 7, 5, 37, 2)
Computes PCASup analysis for the directions concerning the reduced modes.
pcasup2(X, n, m, p, model)
pcasup2(X, n, m, p, model)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
model |
Tucker2 model choice (1 for T2-AB, 2 for T2-AC, 3 for T2-BC) |
A list including the following components:
A |
Matrix of the eingenvectors of the supermatrix containing the frontal slices of the array ( |
B |
Matrix of the eingenvectors of the supermatrix containing the horizontal slices of the array ( |
C |
Matrix of the eingenvectors of the supermatrix containing the lateral slices of the array ( |
la |
Vector of the eigenvalues of the supermatrix containing the frontal slices of the array ( |
lb |
Vector of the eigenvalues of the supermatrix containing the horizontal slices of the array ( |
lc |
Vector of the eigenvalues of the supermatrix containing the lateral slices of the array ( |
Cumulative sum of eigenvalues and fits from PCAsup applied to the reduced modes are automatically printed.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56: 449–470.
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
L.R Tucker (1966). Some mathematical notes on three-mode factor analysis. Psychometrika 31: 279–311.
data(Bus) # PCA-sup for T2-AB pcasupBus <- pcasup2(Bus, 7, 5, 37, 1)
data(Bus) # PCA-sup for T2-AB pcasupBus <- pcasup2(Bus, 7, 5, 37, 1)
Computes PCASup analysis in all the three directions.
pcasup3(X, n, m, p)
pcasup3(X, n, m, p)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
A list including the following components:
A |
Matrix of the eingenvectors of the supermatrix containing the frontal slices of the array ( |
B |
Matrix of the eingenvectors of the supermatrix containing the horizontal slices of the array ( |
C |
Matrix of the eingenvectors of the supermatrix containing the lateral slices of the array ( |
la |
Vector of the eigenvalues of the supermatrix containing the frontal slices of the array ( |
lb |
Vector of the eigenvalues of the supermatrix containing the horizontal slices of the array ( |
lc |
Vector of the eigenvalues of the supermatrix containing the lateral slices of the array ( |
pcasup3
computes the Tucker3 solution according to Tucker (1966).
Cumulative sum of eigenvalues and fits from PCAsup applied to the A
-, B
- and C
-modes are automatically printed.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56: 449–470.
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
L.R Tucker (1966). Some mathematical notes on three-mode factor analysis. Psychometrika 31: 279–311.
data(Bus) ## Not run: # PCA-sup pcasupBus <- pcasup3(Bus, 7, 5, 37) ## End(Not run)
data(Bus) ## Not run: # PCA-sup pcasupBus <- pcasup3(Bus, 7, 5, 37) ## End(Not run)
Computes 2.5% and 97.5% percentiles for all columns of X
.
percentile95(X)
percentile95(X)
X |
Matrix |
A list including the following components:
lo |
Vector of the 2.5% percentiles of the values in the columns of |
up |
Vector of the 97.5% percentiles of the values in the columns of |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(50*3),ncol=3) perc95X <- percentile95(X)
X <- matrix(rnorm(50*3),ncol=3) perc95X <- percentile95(X)
Permutes the matricized (n
x
m
x
p
) array X
to the matricized array Y
of order (m
x
p
x
n
).
permnew(X,n,m,p)
permnew(X,n,m,p)
X |
Matrix (or data.frame coerced to a matrix) containing the matricized array |
n |
Number of |
m |
Number of |
p |
Number of |
Y |
Matrix containing the permuted matricized array |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
X <- array(c(rnorm(120)),c(6,5,4)) dim(X) # matricized array Xa <- supermat(X)$Xa # matricized X with the A-mode entities in its rows dim(Xa) # matricized X with the B-mode entities in its rows Xb <- permnew(Xa, 6, 5, 4) dim(Xb) # matricized X with the C-mode entities in its rows Xc <- permnew(Xb, 5, 4, 6) dim(Xc)
X <- array(c(rnorm(120)),c(6,5,4)) dim(X) # matricized array Xa <- supermat(X)$Xa # matricized X with the A-mode entities in its rows dim(Xa) # matricized X with the B-mode entities in its rows Xb <- permnew(Xa, 6, 5, 4) dim(Xb) # matricized X with the C-mode entities in its rows Xc <- permnew(Xb, 5, 4, 6) dim(Xc)
Gives all the permutations of the first integer numbers.
perms(n)
perms(n)
n |
Integer |
z |
Matrix containing in its rows all the permutation of the first |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2004). Bootstrap confidence intervals for three-way methods. Journal of Chemometrics 18:22–36.
P <- perms(4)
P <- perms(4)
Computes the phi coefficients among columns of two matrices.
phi(a,b)
phi(a,b)
a |
Vector or matrix of the same order of |
b |
Vector or matrix of the same order of |
p |
Matrix containing the phi coefficients |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
L.R Tucker (1951). A method for synthesis of factor analysis studies. Personnel Research Section Report No. 984. Department of the Army, Washington, DC.
X <- matrix(rnorm(6*3),ncol=3) Y <- matrix(rnorm(6*3),ncol=3) P <- phi(X,Y)
X <- matrix(rnorm(6*3),ncol=3) Y <- matrix(rnorm(6*3),ncol=3) P <- phi(X,Y)
Produces an array starting from its matricization with all the frontal slices of the array next to each other.
rarray(Xa, n, m, p)
rarray(Xa, n, m, p)
Xa |
Matrix (or data.frame coerced to a matrix) containing the elements of the frontal slices of an array |
n |
Number of |
m |
Number of |
p |
Number of |
X |
Array leading to |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
# matricized array (frontal slice) Xa <- matrix(1:8,nrow=2) X <- rarray(Xa, 2, 2, 2) # original array X
# matricized array (frontal slice) Xa <- matrix(1:8,nrow=2) X <- rarray(Xa, 2, 2, 2) # original array X
Scales the Candecomp/Parafac solution producing two component matrices normalized to unit sum of squares (and compensating this scaling in the remaining component matrix).
renormsolCP(A, B, C, mode)
renormsolCP(A, B, C, mode)
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
mode |
Scaling option (1 if scaling for B- and C-modes, 2 if scaling for A- and C-modes, 3 if scaling for A- and B-modes) |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # CP solution TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # sums of squares of A, B and C sum(TVcp$A^2) sum(TVcp$B^2) sum(TVcp$C^2) # Renormalization by scaling B- and C-modes TVcpScalBC <- renormsolCP(TVcp$A, TVcp$B, TVcp$C, 1) # sums of squares of A, B and C after renormalization sum(TVcpScalBC$A^2) sum(TVcpScalBC$B^2) sum(TVcpScalBC$C^2)
data(TV) TVdata=TV[[1]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) # CP solution TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000) # sums of squares of A, B and C sum(TVcp$A^2) sum(TVcp$B^2) sum(TVcp$C^2) # Renormalization by scaling B- and C-modes TVcpScalBC <- renormsolCP(TVcp$A, TVcp$B, TVcp$C, 1) # sums of squares of A, B and C after renormalization sum(TVcpScalBC$A^2) sum(TVcpScalBC$B^2) sum(TVcpScalBC$C^2)
Renormalizes the Tucker3 solution producing a core normalized to unit sum of squares (and compensating the core normalization in the component matrices).
renormsolT3(A, B, C, G, mode)
renormsolT3(A, B, C, G, mode)
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
G |
Matricized core array (frontal slices) |
mode |
Renormalization option (1 if renormalization with respect to |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
H |
Normalized matricized core array (frontal slices) |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # sums of squares of A and core sum(BusT3$A^2) sum(BusT3$H^2) # Renormalization with respect to the A-mode BusT3rA <- renormsolT3(BusT3$A, BusT3$B, BusT3$C, BusT3$H,1) # sums of squares of A and core after renormalization sum(BusT3rA$A^2) sum(BusT3rA$H^2)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # sums of squares of A and core sum(BusT3$A^2) sum(BusT3$H^2) # Renormalization with respect to the A-mode BusT3rA <- renormsolT3(BusT3$A, BusT3$B, BusT3$C, BusT3$H,1) # sums of squares of A and core after renormalization sum(BusT3rA$A^2) sum(BusT3rA$H^2)
Performs split-half analysis for Candecomp/Parafac.
splithalfCP(X, n, m, p, r, centopt, normopt, scaleopt, addanal, conv, maxit, ort1, ort2, ort3, laba, labb, labc)
splithalfCP(X, n, m, p, r, centopt, normopt, scaleopt, addanal, conv, maxit, ort1, ort2, ort3, laba, labb, labc)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r |
Number of extracted components |
centopt |
Centering option (see |
normopt |
Normalization option (see |
scaleopt |
Scaling option (see |
addanal |
Number of additional runs |
conv |
Convergence criterion |
maxit |
Maximal number of iterations |
ort1 |
Type of constraints on |
ort2 |
Type of constraints on |
ort3 |
Type of constraints on |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
Afull |
Component matrix for the |
As1 |
Component matrix for the |
As2 |
Component matrix for the |
Bfull |
Component matrix for the |
Bs1 |
Component matrix for the |
Bs2 |
Component matrix for the |
Cfull |
Component matrix for the |
Cs1 |
Component matrix for the |
Cs2 |
Component matrix for the |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) ## Not run: # Split-half analysis on CP solution splitCP <- splithalfCP(TVdata, 30, 16, 15, 2, 0, 0, 0, 5, 1e-6, 10000, 1, 1, 1, labSTUDENT, labSCALE, labPROGRAM) # Split-half analysis on CP solution (when labels are not available) splitCP <- splithalfCP(TVdata, 30, 16, 15, 2, 0, 0, 0, 5, 1e-6, 10000, 1, 1, 1) ## End(Not run)
data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] # permutation of the modes so that the A-mode refers to students TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16) ## Not run: # Split-half analysis on CP solution splitCP <- splithalfCP(TVdata, 30, 16, 15, 2, 0, 0, 0, 5, 1e-6, 10000, 1, 1, 1, labSTUDENT, labSCALE, labPROGRAM) # Split-half analysis on CP solution (when labels are not available) splitCP <- splithalfCP(TVdata, 30, 16, 15, 2, 0, 0, 0, 5, 1e-6, 10000, 1, 1, 1) ## End(Not run)
Performs split-half analysis for Tucker3.
splithalfT3(X, n, m, p, r1, r2, r3, centopt, normopt, renormmode, wa_rel, wb_rel, wc_rel, addanal, conv, laba, labb, labc)
splithalfT3(X, n, m, p, r1, r2, r3, centopt, normopt, renormmode, wa_rel, wb_rel, wc_rel, addanal, conv, laba, labb, labc)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r1 |
Number of extracted components for the |
r2 |
Number of extracted components for the |
r3 |
Number of extracted components for the |
centopt |
Centering option (see |
normopt |
Normalization option (see |
renormmode |
Renormalization option (see |
wa_rel |
Relative weight for simplicity of |
wb_rel |
Relative weight for simplicity of |
wc_rel |
Relative weight for simplicity of |
addanal |
Number of additional runs |
conv |
Convergence criterion |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
Afull |
Component matrix for the |
As1 |
Component matrix for the |
As2 |
Component matrix for the |
Bfull |
Component matrix for the |
Bs1 |
Component matrix for the |
Bs2 |
Component matrix for the |
Cfull |
Component matrix for the |
Cs1 |
Component matrix for the |
Cs2 |
Component matrix for the |
Kfull |
Matricized core array (frontal slices) (full data) |
Ks1 |
Matricized core array (frontal slices) (split n.1) |
Ks2 |
Matricized core array (frontal slices) (split n.2) |
Kss1 |
Matricized core array (frontal slices) (using full data solutions for A,B and C for split n.1) |
Kss2 |
Matricized core array (frontal slices) (using full data solutions for A,B and C for split n.2) |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) ## Not run: # Split-half analysis on T3 solution splitT3 <- splithalfT3(Bus, 7, 5, 37, 2, 2, 2, 0, 0, 0, 3, 3, 0, 5, 1e-6, laba, labb, labc) # Split-half analysis on T3 solution (when labels are not available) splitT3 <- splithalfT3(Bus, 7, 5, 37, 2, 2, 2, 0, 0, 0, 3, 3, 0, 5, 1e-6) ## End(Not run)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) ## Not run: # Split-half analysis on T3 solution splitT3 <- splithalfT3(Bus, 7, 5, 37, 2, 2, 2, 0, 0, 0, 3, 3, 0, 5, 1e-6, laba, labb, labc) # Split-half analysis on T3 solution (when labels are not available) splitT3 <- splithalfT3(Bus, 7, 5, 37, 2, 2, 2, 0, 0, 0, 3, 3, 0, 5, 1e-6) ## End(Not run)
Summary of the elements of a matrix.
SUM(A)
SUM(A)
A |
Matrix or data.frame (coerced to a matrix) |
A list including the following components:
row |
Vector containing the sum of squares of every row |
col |
Vector containing the sum of squares of every column |
mr |
Vector containing the mean of every row |
mc |
Vector containing the mean of every column |
minc |
Vector containing the minimum of every column |
maxc |
Vector containing the maximum of every for column |
valueMinr |
Vector containing the columns corresponding to the minimum values of every row |
valueMinc |
Vector containing the rows corresponding to the minimum values of every column |
valueMaxr |
Vector containing the columns corresponding to the maximum values of every row |
valueMaxc |
Vector containing the rows corresponding to the maximum values of every column |
ssq |
Sum of squares of the matrix |
cumsumr |
Matrix containing the cumulative sums of every row |
cumsumc |
Matrix containing the cumulative sums of every column |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(6*3),ncol=3) summary <- SUM(X)
X <- matrix(rnorm(6*3),ncol=3) summary <- SUM(X)
Produces matricizations of a three-way array into matrices denoted as super-matrices.
supermat(X)
supermat(X)
X |
Array to be unfolded |
A list including the following components:
Xa |
Super-matrix with |
Xb |
Super-matrix with |
Xc |
Super-matrix with |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (2000). Towards a standardized notation and terminology in multiway analysis. Journal of Chemometrics 14:105–122.
# array (2x2x2) with integers from 1 to 8 X <- array(1:8,c(2,2,2)) Y <- supermat(X) # matricized arrays Y$Xa Y$Xb Y$Xc
# array (2x2x2) with integers from 1 to 8 X <- array(1:8,c(2,2,2)) Y <- supermat(X) # matricized arrays Y$Xa Y$Xb Y$Xc
Detects the underlying structure of a three-way array according to the Tucker1 (T1) model.
T1(dati, laba, labb, labc)
T1(dati, laba, labb, labc)
dati |
Array of order |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
core |
Matricized core array (frontal slices) |
fit |
Fit value expressed as a percentage |
fitA |
Fit contributions for the |
fitB |
Fit contributions for the |
fitC |
Fit contributions for the |
laba |
Vector of length |
labb |
Vector of length |
labc |
Vector of length |
Xprep |
Matrix of order ( |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P. Giordani, H.A.L. Kiers, M.A. Del Ferraro (2014). Three-way component analysis using the R package ThreeWay. Journal of Statistical Software 57(7):1–23. http://www.jstatsoft.org/v57/i07/.
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
L.R Tucker (1966). Some mathematical notes on three-mode factor analysis. Psychometrika 31:279–311.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) ## Not run: # interactive T1 analysis BusT1 <- T1(Bus, laba, labb, labc) # interactive T1 analysis (when labels are not available) BusT1 <- T1(Bus) ## End(Not run)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) ## Not run: # interactive T1 analysis BusT1 <- T1(Bus, laba, labb, labc) # interactive T1 analysis (when labels are not available) BusT1 <- T1(Bus) ## End(Not run)
Computes all the Tucker1 solutions using PCASup results with r1
(from 1 to maxa
, if A
-mode reduced), r2
(from 1 to maxb
, if B
-mode reduced) and r3
(from 1 to maxc
, if C
-mode reduced) components.
T1runsFit(X, n, m, p, maxa, maxb, maxc, model)
T1runsFit(X, n, m, p, maxa, maxb, maxc, model)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
maxa |
Maximum dimensionality for the |
maxb |
Maximum dimensionality for the |
maxc |
Maximum dimensionality for the |
model |
Tucker1 model choice (1 for T1-A, 2 for T1-B, 3 for T2-C) |
out |
Matrix with columns: number of components for the |
Cumulative sum of eigenvalues and fits from PCAsup applied to the reduced mode are automatically printed.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56:449–470.
DimSelector
, LineCon
, pcasup1
, T1
data(Bus) # Fit values of T1-A with different numbers of components (from 1 to 5) FitT1 <- T1runsFit(Bus, 7, 5, 37, 5, 5, 37, 1)
data(Bus) # Fit values of T1-A with different numbers of components (from 1 to 5) FitT1 <- T1runsFit(Bus, 7, 5, 37, 5, 5, 37, 1)
Detects the underlying structure of a three-way array according to the Tucker2 (T2) model.
T2(dati, laba, labb, labc)
T2(dati, laba, labb, labc)
dati |
Array of order |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
core |
Matricized core array (frontal slices) |
fit |
Fit value expressed as a percentage |
fitValues |
Fit values expressed as a percentage upon convergence for all the runs of the CP algorithm (see |
funcValues |
Function values upon convergence for all the runs of the CP algorithm (see |
cputime |
Computation times for all the runs of the CP algorithm (see |
iter |
Numbers of iterations upon convergence for all the runs of the CP algorithm (see |
fitA |
Fit contributions for the |
fitB |
Fit contributions for the |
fitC |
Fit contributions for the |
fitAB |
Fit contributions for the |
fitAC |
Fit contributions for the |
fitBC |
Fit contributions for the |
laba |
Vector of length |
labb |
Vector of length |
labc |
Vector of length |
Xprep |
Matrix of order ( |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P. Giordani, H.A.L. Kiers, M.A. Del Ferraro (2014). Three-way component analysis using the R package ThreeWay. Journal of Statistical Software 57(7):1–23. http://www.jstatsoft.org/v57/i07/.
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
L.R Tucker (1966). Some mathematical notes on three-mode factor analysis. Psychometrika 31:279–311.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) ## Not run: # interactive T2 analysis BusT2 <- T2(Bus, laba, labb, labc) # interactive T2 analysis (when labels are not available) BusT2 <- T2(Bus) ## End(Not run)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) ## Not run: # interactive T2 analysis BusT2 <- T2(Bus, laba, labb, labc) # interactive T2 analysis (when labels are not available) BusT2 <- T2(Bus) ## End(Not run)
Alternating Least Squares algorithm for the minimization of the Tucker2 loss function.
T2func(X, n, m, p, r1, r2, r3, start, conv, model, A, B, C, H)
T2func(X, n, m, p, r1, r2, r3, start, conv, model, A, B, C, H)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r1 |
Number of extracted components for the |
r2 |
Number of extracted components for the |
r3 |
Number of extracted components for the |
start |
Starting point: 0 starting point of the algorithm from generalized eigenvalue decomposition, 1 random starting point (orthonormalized component matrices), 2 if users specified component matrices |
conv |
Convergence criterion |
model |
Tucker2 model choice (1 for T2-AB, 2 for T2-AC, 3 for T2-BC) |
A |
Optional (necessary if start=2) starting value for |
B |
Optional (necessary if start=2) starting value for |
C |
Optional (necessary if start=2) starting value for |
H |
Optional (necessary if start=2) starting value for the matricized core array (frontal slices) |
A list including the following components:
A |
Orthonormal component matrix for the |
B |
Orthonormal component matrix for the |
C |
Orthonormal component matrix for the |
H |
Matricized core array (frontal slices) |
f |
Loss function value |
fp |
Fit percentage |
iter |
Number of iterations |
cputime |
Computation time |
La |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lb |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lc |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
The loss function to be minimized is where
and
denote the matricized (frontal slices) data array and core array, respectively, and kron stands for the Kronecker product.
T2func
is the same as T2funcrep
except that all printings are available.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers, P.M. Kroonenberg \& J.M.F. ten Berge (1992). An efficient algorithm for TUCKALS3 on data with large numbers of observation units. Psychometrika 57:415–422.
P.M. Kroonenberg and J. de Leeuw (1980). Principal component analysis of three-mode data by means of alternating least squares algorithms. Psychometrika 45:69–97.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T2-AB solution using two components for the A- and B-modes # (rational starting point by SVD [start=0]) BusT2 <- T2func(Bus, 7, 5, 37, 2, 2, 37, 0, 1e-6, 1) # T2-AC solution using two components for for the A- and C-modes # (random orthonormalized starting point [start=1]) BusT2 <- T2func(Bus, 7, 5, 37, 2, 5, 2, 1, 1e-6, 2) # T2-BC solution using two components for the B- and C- modes # (user starting point [start=2]) BusT2 <- T2func(Bus, 7, 5, 37, 7, 2, 2, 1, 1e-6, 3, diag(7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(7*4),nrow=7))
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T2-AB solution using two components for the A- and B-modes # (rational starting point by SVD [start=0]) BusT2 <- T2func(Bus, 7, 5, 37, 2, 2, 37, 0, 1e-6, 1) # T2-AC solution using two components for for the A- and C-modes # (random orthonormalized starting point [start=1]) BusT2 <- T2func(Bus, 7, 5, 37, 2, 5, 2, 1, 1e-6, 2) # T2-BC solution using two components for the B- and C- modes # (user starting point [start=2]) BusT2 <- T2func(Bus, 7, 5, 37, 7, 2, 2, 1, 1e-6, 3, diag(7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(7*4),nrow=7))
Alternating Least Squares algorithm for the minimization of the Tucker2 loss function.
T2funcrep(X, n, m, p, r1, r2, r3, start, conv, model, A, B, C, H)
T2funcrep(X, n, m, p, r1, r2, r3, start, conv, model, A, B, C, H)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r1 |
Number of extracted components for the |
r2 |
Number of extracted components for the |
r3 |
Number of extracted components for the |
start |
Starting point: 0 starting point of the algorithm from generalized eigenvalue decomposition, 1 random starting point (orthonormalized component matrices), 2 if users specified component matrices |
conv |
Convergence criterion |
model |
Tucker2 model choice (1 for T2-AB, 2 for T2-AC, 3 for T2-BC) |
A |
Optional (necessary if start=2) starting value for |
B |
Optional (necessary if start=2) starting value for |
C |
Optional (necessary if start=2) starting value for |
H |
Optional (necessary if start=2) starting value for the matricized core array (frontal slices) |
A list including the following components:
A |
Orthonormal component matrix for the |
B |
Orthonormal component matrix for the |
C |
Orthonormal component matrix for the |
H |
Matricized core array (frontal slices) |
f |
Loss function value |
fp |
Fit percentage |
iter |
Number of iterations |
cputime |
Computation time |
La |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lb |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lc |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
The loss function to be minimized is where
and
denote the matricized (frontal slices) data array and core array, respectively, and kron stands for the Kronecker product.
T2funcrep
is the same as T2func
except that all printings are suppressed. Thus, T2funcrep
can be helpful for simulation experiments.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers, P.M. Kroonenberg \& J.M.F. ten Berge (1992). An efficient algorithm for TUCKALS3 on data with large numbers of observation units. Psychometrika 57:415–422.
P.M. Kroonenberg and J. de Leeuw (1980). Principal component analysis of three-mode data by means of alternating least squares algorithms. Psychometrika 45:69–97.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T2-AB solution using two components for the A- and B-modes # (rational starting point by SVD [start=0]) BusT2 <- T2funcrep(Bus, 7, 5, 37, 2, 2, 37, 0, 1e-6,1) # T2-AC solution using two components for for the A- and C-modes # (random orthonormalized starting point [start=1]) BusT2 <- T2funcrep(Bus, 7, 5, 37, 2, 5, 2, 1, 1e-6, 2) # T2-BC solution using two components for the B- and C- modes # (user starting point [start=2]) BusT2 <- T2funcrep(Bus, 7, 5, 37, 7, 2, 2, 1, 1e-6, 3, diag(7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(7*4),nrow=7))
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T2-AB solution using two components for the A- and B-modes # (rational starting point by SVD [start=0]) BusT2 <- T2funcrep(Bus, 7, 5, 37, 2, 2, 37, 0, 1e-6,1) # T2-AC solution using two components for for the A- and C-modes # (random orthonormalized starting point [start=1]) BusT2 <- T2funcrep(Bus, 7, 5, 37, 2, 5, 2, 1, 1e-6, 2) # T2-BC solution using two components for the B- and C- modes # (user starting point [start=2]) BusT2 <- T2funcrep(Bus, 7, 5, 37, 7, 2, 2, 1, 1e-6, 3, diag(7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(7*4),nrow=7))
Computes all the approximated Tucker2 solutions using PCASup results with r1
(from 1 to maxa
, if A
-mode reduced), r2
(from 1 to maxb
, if B
-mode reduced) and r3
(from 1 to maxc
, if C
-mode reduced) components.
T2runsApproxFit(X, n, m, p, maxa, maxb, maxc, model)
T2runsApproxFit(X, n, m, p, maxa, maxb, maxc, model)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
maxa |
Maximum dimensionality for the |
maxb |
Maximum dimensionality for the |
maxc |
Maximum dimensionality for the |
model |
Tucker2 model choice (1 for T2-AB, 2 for T2-AC, 3 for T2-BC) |
out |
Matrix with columns: number of components for the |
Cumulative sum of eigenvalues and fits from PCAsup applied to the reduced modes are automatically printed.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56:449–470.
DimSelector
, LineCon
, pcasup2
, T2
data(Bus) # Fit values of T2-AB with different numbers of components # (from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT2 <- T2runsApproxFit(Bus, 7, 5, 37, 7, 3, 5, 3)
data(Bus) # Fit values of T2-AB with different numbers of components # (from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT2 <- T2runsApproxFit(Bus, 7, 5, 37, 7, 3, 5, 3)
Detects the underlying structure of a three-way array according to the Tucker3 (T3) model.
T3(data, laba, labb, labc)
T3(data, laba, labb, labc)
data |
Array of order |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
A |
Component matrix for the |
B |
Component matrix for the |
C |
Component matrix for the |
core |
Matricized core array (frontal slices) |
fit |
Fit value expressed as a percentage |
fitValues |
Fit values expressed as a percentage upon convergence for all the runs of the CP algorithm (see |
funcValues |
Function values upon convergence for all the runs of the CP algorithm (see |
cputime |
Computation times for all the runs of the CP algorithm (see |
iter |
Numbers of iterations upon convergence for all the runs of the CP algorithm (see |
fitA |
Fit contributions for the |
fitB |
Fit contributions for the |
fitC |
Fit contributions for the |
fitAB |
Fit contributions for the |
fitAC |
Fit contributions for the |
fitBC |
Fit contributions for the |
Bint |
Bootstrap percentile interval of every element of |
Cint |
Bootstrap percentile interval of every element of |
Kint |
Bootstrap percentile interval of every element of |
fpint |
Bootstrap percentile interval for the goodness of fit index expressed as a percentage (see |
Afull |
Component matrix for the |
As1 |
Component matrix for the |
As2 |
Component matrix for the |
Bfull |
Component matrix for the |
Bs1 |
Component matrix for the |
Bs2 |
Component matrix for the |
Cfull |
Component matrix for the |
Cs1 |
Component matrix for the |
Cs2 |
Component matrix for the |
Kfull |
Matricized core array (frontal slices) (full data) from split-half analysis (see |
Ks1 |
Matricized core array (frontal slices) (split n.1) from split-half analysis (see |
Ks2 |
Matricized core array (frontal slices) (split n.2) from split-half analysis (see |
Kss1 |
Matricized core array (frontal slices) (using full data solutions for A,B and C for split n.1) from split-half analysis (see |
Kss2 |
Matricized core array (frontal slices) (using full data solutions for A,B and C for split n.2) from split-half analysis (see |
Aplot |
Coordinates for plots of the |
Bplot |
Coordinates for plots of the |
Cplot |
Coordinates for plots of the |
CBplot |
Coordinates for plots of the |
ACplot |
Coordinates for plots of the |
BAplot |
Coordinates for plots of the |
A1 |
Component matrix for the |
B1 |
Component matrix for the |
C1 |
Component matrix for the |
A2 |
Component matrix for the |
B2 |
Component matrix for the |
C2 |
Component matrix for the |
laba |
Vector of length |
labb |
Vector of length |
labc |
Vector of length |
Xprep |
Matrix of order ( |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
P. Giordani, H.A.L. Kiers, M.A. Del Ferraro (2014). Three-way component analysis using the R package ThreeWay. Journal of Statistical Software 57(7):1–23. http://www.jstatsoft.org/v57/i07/.
P.M. Kroonenberg (2008). Applied Multiway Data Analysis. Wiley, New Jersey.
L.R Tucker (1966). Some mathematical notes on three-mode factor analysis. Psychometrika 31:279–311.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) ## Not run: # interactive T3 analysis BusT3 <- T3(Bus, laba, labb, labc) # interactive T3 analysis (when labels are not available) BusT3 <- T3(Bus) ## End(Not run)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5],1,1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)],3,8) ## Not run: # interactive T3 analysis BusT3 <- T3(Bus, laba, labb, labc) # interactive T3 analysis (when labels are not available) BusT3 <- T3(Bus) ## End(Not run)
Plots fits against numbers of dimensions, with PQR
as labels and fits against number of effective paramaters.
T3dimensionalityplot(A, n, m, p)
T3dimensionalityplot(A, n, m, p)
A |
Matrix with columns: number of components for the |
n |
Number of |
m |
Number of |
p |
Number of |
A
is usually the output of DimSelector
.
The number of effective parameters in a Candecomp/Parafac analysis is discussed in Weesie and Van Houwelingen (1983).
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
E. Ceulemans \& H.A.L. Kiers (2006). Selecting among three-mode principal component models of different types and complexities: A numerical convex hull based method. British Journal of Mathematical and Statistical Psychology 59:133–150.
J. Weesie and H. Van Houwelingen (1983). GEPCAM users' manual (first draft). Utrecht, The Netherlands: Institute of Mathematical Statistics, State University of Utrecht.
data(Bus) # Fit values of T3 with different numbers of components (from 1 to 4 for the A-mode, # from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT3 <- T3runsApproxFit(Bus,7,5,37,4,3,5) T3dimensionalityplot(FitT3,7,5,37)
data(Bus) # Fit values of T3 with different numbers of components (from 1 to 4 for the A-mode, # from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT3 <- T3runsApproxFit(Bus,7,5,37,4,3,5) T3dimensionalityplot(FitT3,7,5,37)
Computation of fit contributions by combinations of modes in case of ‘renormalization’.
T3fitpartitioning(Xprep, n, m, p, AS, BT, CU, K, renormmode, laba, labb, labc)
T3fitpartitioning(Xprep, n, m, p, AS, BT, CU, K, renormmode, laba, labb, labc)
Xprep |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
AS |
Component matrix for the |
BT |
Component matrix for the |
CU |
Component matrix for the |
K |
Matricized core array (frontal slices) |
renormmode |
Renormalization option (0 for no renormalization, 1 for fit contribution to total fit of each |
laba |
Optional vector of length |
labb |
Optional vector of length |
labc |
Optional vector of length |
A list including the following components:
fitA |
Fit contribution for the |
fitB |
Fit contribution for the |
fitC |
Fit contribution for the |
ABcontr |
Contribution to the goodness of fit contributions by combinations of |
BCcontr |
Contribution to the goodness of fit contributions by combinations of |
ACcontr |
Contribution to the goodness of fit contributions by combinations of |
The computation of the fit contributions by combinations of modes is done in case of ‘renormalization’.
In Tucker1, renormmode
must be equal to 0.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # Fitpartitioning of the T3 solution FitT3 <- T3fitpartitioning(Bus, 7, 5, 37, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 0, laba, labb, labc) # Fitpartitioning of the T3 solution (when labels are not available) FitT3 <- T3fitpartitioning(Bus, 7, 5, 37, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 0)
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # Fitpartitioning of the T3 solution FitT3 <- T3fitpartitioning(Bus, 7, 5, 37, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 0, laba, labb, labc) # Fitpartitioning of the T3 solution (when labels are not available) FitT3 <- T3fitpartitioning(Bus, 7, 5, 37, BusT3$A, BusT3$B, BusT3$C, BusT3$H, 0)
Alternating Least Squares algorithm for the minimization of the Tucker3 loss function.
T3func(X, n, m, p, r1, r2, r3, start, conv, A, B, C, H)
T3func(X, n, m, p, r1, r2, r3, start, conv, A, B, C, H)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r1 |
Number of extracted components for the |
r2 |
Number of extracted components for the |
r3 |
Number of extracted components for the |
start |
Starting point (0 starting point of the algorithm from generalized eigenvalue decomposition, 1 random starting point (orthonormalized component matrices), 2 if users specified component matrices |
conv |
Convergence criterion |
A |
Optional (necessary if start=2) starting value for |
B |
Optional (necessary if start=2) starting value for |
C |
Optional (necessary if start=2) starting value for |
H |
Optional (necessary if start=2) starting value for the matricized core array (frontal slices) |
A list including the following components:
A |
Orthonormal component matrix for the |
B |
Orthonormal component matrix for the |
C |
Orthonormal component matrix for the |
H |
Matricized core array (frontal slices) |
f |
Loss function value |
fp |
Fit percentage |
iter |
Number of iterations |
cputime |
Computation time |
La |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lb |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lc |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
The loss function to be minimized is where
and
denote the matricized (frontal slices) data array and core array, respectively, and kron stands for the Kronecker product.
T3func
is the same as T3funcrep
except that all printings are available.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers, P.M. Kroonenberg \& J.M.F. ten Berge (1992). An efficient algorithm for TUCKALS3 on data with large numbers of observation units. Psychometrika 57:415–422.
P.M. Kroonenberg \& J. de Leeuw (1980). Principal component analysis of three-mode data by means of alternating least squares algorithms. Psychometrika 45:69–97.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution using two components for all the modes # (rational starting point by SVD [start=0]) BusT3 <- T3func(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # T3 solution using two components for all the modes # (random orthonormalized starting point [start=1]) BusT3 <- T3func(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6) # T3 solution using two components for all the modes # (user starting point [start=2]) BusT3 <- T3func(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6, matrix(rnorm(7*2),nrow=7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(2*4),nrow=2))
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution using two components for all the modes # (rational starting point by SVD [start=0]) BusT3 <- T3func(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # T3 solution using two components for all the modes # (random orthonormalized starting point [start=1]) BusT3 <- T3func(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6) # T3 solution using two components for all the modes # (user starting point [start=2]) BusT3 <- T3func(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6, matrix(rnorm(7*2),nrow=7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(2*4),nrow=2))
Alternating Least Squares algorithm for the minimization of the Tucker3 loss function.
T3funcrep(X, n, m, p, r1, r2, r3, start, conv, A, B, C, H)
T3funcrep(X, n, m, p, r1, r2, r3, start, conv, A, B, C, H)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
r1 |
Number of extracted components for the |
r2 |
Number of extracted components for the |
r3 |
Number of extracted components for the |
start |
Starting point (0 starting point of the algorithm from generalized eigenvalue decomposition, 1 random starting point (orthonormalized component matrices), 2 if users specified component matrices |
conv |
Convergence criterion |
A |
Optional (necessary if start=2) starting value for |
B |
Optional (necessary if start=2) starting value for |
C |
Optional (necessary if start=2) starting value for |
H |
Optional (necessary if start=2) starting value for the matricized core array (frontal slices) |
A list including the following components:
A |
Orthonormal component matrix for the |
B |
Orthonormal component matrix for the |
C |
Orthonormal component matrix for the |
H |
Matricized core array (frontal slices) |
f |
Loss function value |
fp |
Fit percentage |
iter |
Number of iterations |
cputime |
Computation time |
La |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lb |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
Lc |
Matrix which should be diagonal, and if so, contain ‘intrinsic eigenvalues’ for |
The loss function to be minimized is where
and
denote the matricized (frontal slices) data array and core array, respectively, and kron stands for the Kronecker product.
T3funcrep
is the same as T3func
except that all printings are suppressed. Thus, T3funcrep
can be helpful for simulation experiments.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers, P.M. Kroonenberg \& J.M.F. ten Berge (1992). An efficient algorithm for TUCKALS3 on data with large numbers of observation units. Psychometrika 57:415–422.
P.M. Kroonenberg \& J. de Leeuw (1980). Principal component analysis of three-mode data by means of alternating least squares algorithms. Psychometrika 45:69–97.
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution using two components for all the modes # (rational starting point by SVD [start=0]) BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # T3 solution using two components for all the modes # (random orthonormalized starting point [start=1]) BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6) # T3 solution using two components for all the modes # (user starting point [start=2]) BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6, matrix(rnorm(7*2),nrow=7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(2*4),nrow=2))
data(Bus) # labels for Bus data laba <- rownames(Bus) labb <- substr(colnames(Bus)[1:5], 1, 1) labc <- substr(colnames(Bus)[seq(1,ncol(Bus),5)], 3, 8) # T3 solution using two components for all the modes # (rational starting point by SVD [start=0]) BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # T3 solution using two components for all the modes # (random orthonormalized starting point [start=1]) BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6) # T3 solution using two components for all the modes # (user starting point [start=2]) BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 1, 1e-6, matrix(rnorm(7*2),nrow=7), matrix(rnorm(5*2),nrow=5), matrix(rnorm(37*2),nrow=37), matrix(rnorm(2*4),nrow=2))
Computes all the approximated Tcker3 solutions using PCASup results with r1
(from 1 to maxa
), r2
(from 1 to maxb
) and r3
(from 1 to maxc
) components.
T3runsApproxFit(X, n, m, p, maxa, maxb, maxc)
T3runsApproxFit(X, n, m, p, maxa, maxb, maxc)
X |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
maxa |
Maximum dimensionality for the |
maxb |
Maximum dimensionality for the |
maxc |
Maximum dimensionality for the |
out |
Matrix with columns: number of components for the |
Cumulative sum of eigenvalues and fits from PCAsup applied to the A
-, B
- and C
-modes are automatically printed.
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56:449–470.
DimSelector
, LineCon
, pcasup3
, T3
data(Bus) # Fit values of T3 with different numbers of components (from 1 to 4 for the A-mode, # from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT3 <- T3runsApproxFit(Bus, 7, 5, 37, 4, 3, 5)
data(Bus) # Fit values of T3 with different numbers of components (from 1 to 4 for the A-mode, # from 1 to 3 for the B-mode, from 1 to 5 for the C-mode) FitT3 <- T3runsApproxFit(Bus, 7, 5, 37, 4, 3, 5)
Computation of three-way Analysis of Variance (ANOVA).
threewayanova(Y, n, m, p)
threewayanova(Y, n, m, p)
Y |
Matrix (or data.frame coerced to a matrix) of order ( |
n |
Number of |
m |
Number of |
p |
Number of |
A list including the following components:
SS.a |
Main effect for the |
SS.b |
Main effect for the |
SS.c |
Main effect for the |
SS.ab |
Second order interaction ( |
SS.bc |
Second order interaction ( |
SS.ac |
Second order interaction ( |
SS.abc |
Residual sum of squares after subtraction of second order interactions |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers \& I. Van Mechelen (2001). Three-way component analysis: principles and illustrative applications. Psychological Methods 6:84–110.
data(TV) TVdata=TV[[1]] anova3 <- threewayanova(TVdata, 16, 15, 30)
data(TV) TVdata=TV[[1]] anova3 <- threewayanova(TVdata, 16, 15, 30)
Computes the trace of a matrix.
tr(a)
tr(a)
a |
Matrix |
t |
Trace of |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
X <- matrix(rnorm(6*6),ncol=6) trace <- tr(X)
X <- matrix(rnorm(6*6),ncol=6) trace <- tr(X)
Three-way data about ratings of 15 American television shows on 16 bipolar scales made by 30 students.
data(TV)
data(TV)
A list containing one data.frame and three character vectors.
TV[[1]]
is a data.frame with 16 rows and 450 (15 x
30) columns.
The rows refer to the American television shows.
The columns refer to the combinations of scales and students with the sclaes nested within the students.
The data.frame contains the frontal slices next to each other of the original array.
The labels for the bipolar scales are in the character vector TV[[2]]
.
The labels for the TV programs are in the character vector TV[[3]]
.
The labels for the students are in the character vector TV[[4]]
.
The original data set consists of ratings made by 40 subjects (psychology students at the University of Western Ontario in 1981). To avoid missing data, only 30 students are considered. The ratings are made on 13-point bipolar scales. Lundy et al. (1989) perform Candecomp/Parafac on the preprocessed data. Details on preprocessing are not reported, but should be centered within TV programs and scales. Three real components are extracted. However, the unconstrained Candecomp/Parafac solution with three components suffers from the so-called degeneracy (obtained solution with highly correlated and uninterpretable dimensions). Degeneracy (see, for instance, Harshman \& Lundy, 1984; Stegeman, 2006, 2007; De Silva \& Lim, 2008; Rocci \& Giordani, 2010) can be overcome by imposing orthogonal constraints in one of the component matrices. The so-obtained solution with three components is meaningful and interpretable as described in Lundy et al. (1989).
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
V. De Silva \& L.-H. Lim (2008). Tensor rank and the ill-posedness of the best low-rank approximation problem. SIAM Journal on Matrix Analysis and Applications 30:1084–1127.
R.A. Harshman \& M.E. Lundy (1984). Data preprocessing and the extended PARAFAC model. In H.G. Law, C.W. Snyder Jr, J.A. Hattie, \& R.P. McDonald (Eds.): Research methods for multimode data analysis. Praeger, New York (pp. 216–284).
M.E. Lundy, R.A. Harshman \& J.B. Kruskal (1989). A two-stage procedure incorporating good features of both trilinear and quadrilinear models. In R. Coppi, S. Bolasco (Eds.): Multiway Data Analysis. Elsevier, North Holland (pp. 123–130).
R. Rocci R \& P. Giordani (2010). A weak degeneracy decomposition for the CANDECOMP/PARAFAC model. Journal of Chemometrics 24:57–66.
A. Stegeman (2006). Degeneracy in Candecomp/Parafac explained for pxpx2
arrays of rank p+1 or higher. Psychometrika 71:483–501.
A. Stegeman (2007). Degeneracy in Candecomp/Parafac and Indscal explained for several three-sliced arrays with a two-valued typical rank. Psychometrika 72:601–619.
# to perform stability check and produce bootstrap confidence intervals # it is useful to permute the modes so that the A-mode refers to students data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16)
# to perform stability check and produce bootstrap confidence intervals # it is useful to permute the modes so that the A-mode refers to students data(TV) TVdata=TV[[1]] labSCALE=TV[[2]] labPROGRAM=TV[[3]] labSTUDENT=TV[[4]] TVdata <- permnew(TVdata, 16, 15, 30) TVdata <- permnew(TVdata, 15, 30, 16)
Produces varimax rotated version of A
and rotation matrix T
.
varim(A)
varim(A)
A |
Matrix to be to be rotated |
A list including the following components:
B |
Rotated version of |
T |
Rotation matrix |
f |
Varimax function value |
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H. Kaiser (1958). The varimax criterion for analytic rotation in factor analysis. Psychometrika 23:187–200.
K. Nevels (1986). A direct solution for pairwise rotations in Kaiser's varimax method. Psychometrika 51:327–329.
X <- matrix(rnorm(6*3),ncol=3) Y <- varim(X) # varimax rotated version of X Y$B # rotation matrix Y$T
X <- matrix(rnorm(6*3),ncol=3) Y <- varim(X) # varimax rotated version of X Y$B # rotation matrix Y$T
Performs varimax rotation of the core and component matrix rotations to simple structure.
varimcoco(A, B, C, H, wa_rel, wb_rel, wc_rel, rot1, rot2, rot3, nanal)
varimcoco(A, B, C, H, wa_rel, wb_rel, wc_rel, rot1, rot2, rot3, nanal)
A |
Columnwise orthomornal component matrix for the |
B |
Columnwise orthomornal component matrix for the |
C |
Columnwise orthomornal component matrix for the |
H |
Matricized core array (frontal slices) |
wa_rel |
relative weight (>=0) for the simplicity of |
wb_rel |
relative weight (>=0) for the simplicity of |
wc_rel |
relative weight (>=0) for the simplicity of |
rot1 |
binary indicator (1 if the |
rot2 |
binary indicator (1 if the |
rot3 |
binary indicator (1 if the |
nanal |
Number of random starts, default 5 |
A list including the following components:
AS |
Rotated component matrix for the |
BT |
Rotated component matrix for the |
CU |
Rotated component matrix for the |
K |
Rotated matricized core array (frontal slices) |
S |
Rotation matrix for the |
T |
Rotation matrix for the |
U |
Rotation matrix for the |
f |
Best solution for three-way orthomax function value |
f1 |
Varimax value of |
f2a |
Varimax value of |
f2b |
Varimax value of |
f2c |
Varimax value of |
func |
Function values upon convergence for all the runs of the orthomax algorithm |
The simplicity values f1
, f2a
, f2b
, f2c
are based on ‘natural’
weigths and therefore comparable across matrices. When multiplied by the relative weights,
they give the contribution to the overall simplicity value (they are I^2/p
, J^2/q
or K^2/r
,
respectively, times the sum of the variances of squared values).
Maria Antonietta Del Ferraro [email protected]
Henk A.L. Kiers [email protected]
Paolo Giordani [email protected]
H.A.L. Kiers (1998). Joint orthomax rotation of the core and component matrices resulting from three-mode principal components analysis. Journal of Classification 15:245–263.
data(Bus) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # Simplicity of A (with weight = 2.5), B (with weight = 2) and C (with weight = 1.5) T3vmABC <- varimcoco(BusT3$A, BusT3$B, BusT3$C, BusT3$H, 2.5, 2, 1.5) # Simplicity of only A (with weight = 2.5) and B (with weight = 2) # rot3=0; the value of wc_rel (= 0) does not play an active role T3vmAB <- varimcoco(BusT3$A, BusT3$B, BusT3$C, BusT3$H, 2.5, 2, 0, 1, 1, 0) # simplicity repeatedly with different relative weights for A, B and C T3vm <- list() weight.a <- c(1, 3, 6) weight.b <- c(0, 2, 5) weight.c <- c(1, 4) i <- 1 for (wa_rel in weight.a){ for (wb_rel in weight.b){ for (wc_rel in weight.c){ T3vm[[i]] <- varimcoco(BusT3$A, BusT3$B, BusT3$C, BusT3$H, wa_rel, wb_rel, wc_rel) i <- i+1 } } }
data(Bus) # T3 solution BusT3 <- T3funcrep(Bus, 7, 5, 37, 2, 2, 2, 0, 1e-6) # Simplicity of A (with weight = 2.5), B (with weight = 2) and C (with weight = 1.5) T3vmABC <- varimcoco(BusT3$A, BusT3$B, BusT3$C, BusT3$H, 2.5, 2, 1.5) # Simplicity of only A (with weight = 2.5) and B (with weight = 2) # rot3=0; the value of wc_rel (= 0) does not play an active role T3vmAB <- varimcoco(BusT3$A, BusT3$B, BusT3$C, BusT3$H, 2.5, 2, 0, 1, 1, 0) # simplicity repeatedly with different relative weights for A, B and C T3vm <- list() weight.a <- c(1, 3, 6) weight.b <- c(0, 2, 5) weight.c <- c(1, 4) i <- 1 for (wa_rel in weight.a){ for (wb_rel in weight.b){ for (wc_rel in weight.c){ T3vm[[i]] <- varimcoco(BusT3$A, BusT3$B, BusT3$C, BusT3$H, wa_rel, wb_rel, wc_rel) i <- i+1 } } }