Algorithm for the Candecomp/Parafac (CP) model
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)
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 sum(k)|| X(k) - A D(k) B' ||^2, where D(k) 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 mariaantonietta.delferraro@yahoo.it 
 Henk A.L. Kiers h.a.l.kiers@rug.nl 
 Paolo Giordani paolo.giordani@uniroma1.it
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))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.