CPfuncrep: Algorithm for the Candecomp/Parafac (CP) model

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

Alternating Least Squares algorithm for the minimization of the Candecomp/Parafac loss function.

Usage

1
 CPfuncrep(X, n, m, p, r, ort1, ort2, ort3, start, conv, maxit, A, B, C)

Arguments

X

Matrix (or data.frame coerced to a matrix) of order (n x mp) containing the matricized array (frontal slices)

n

Number of A-mode entities

m

Number of B-mode entities

p

Number of C-mode entities

r

Number of extracted components

ort1

Type of constraints on A (1 for no constraints, 2 for orthogonality constraints, 3 for zero correlations constraints)

ort2

Type of constraints on B (1 for no constraints, 2 for orthogonality constraints, 3 for zero correlations constraints)

ort3

Type of constraints on C (1 for no constraints, 2 for orthogonality constraints, 3 for zero correlations constraints)

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 A

B

Optional (necessary if start=2) starting value for B

C

Optional (necessary if start=2) starting value for C

Value

A list including the following components:

A

Component matrix for the A-mode

B

Component matrix for the B-mode

C

Component matrix for the C-mode

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

Note

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.
CPfuncrep is the same as CPfunc except that all printings are suppressed. Thus, CPfuncrep can be helpful for simulation experiments.

Author(s)

Maria Antonietta Del Ferraro mariaantonietta.delferraro@yahoo.it
Henk A.L. Kiers h.a.l.kiers@rug.nl
Paolo Giordani paolo.giordani@uniroma1.it

References

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.

See Also

CP, CPfunc

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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))

ThreeWay documentation built on May 2, 2019, 9:20 a.m.

Related to CPfuncrep in ThreeWay...