cp_als | R Documentation |
Alternating Least Squares (ALS) algorithm with optional constraints for the minimization of the Candecomp/Parafac (CP) loss function.
cp_als(
X,
n,
m,
p,
ncomp,
const = "none",
start = "random",
conv = 1e-06,
maxit = 10000,
trace = FALSE
)
X |
A three-way array or a matrix. If |
n |
Number of A-mode entities |
m |
Number of B-mode entities |
p |
Number of C-mode entities |
ncomp |
Number of components to extract |
const |
Optional constraints for each mode. Can be a three element
character vector or a single character, one of |
start |
Initial values for the A, B and C components. Can be
|
conv |
Convergence criterion, default is |
maxit |
Maximum number of iterations, default is |
trace |
Logical, provide trace output. |
The result of the decomposition as a list with the following elements:
fit
Value of the loss function
fp
Fit value expressed as a percentage
ss
Sum of squares
A
Component matrix for the A-mode
B
Component matrix for the B-mode
C
Component matrix for the C-mode
iter
Number of iterations
tripcos
Minimal triple cosine between two components
across the three component matrices, used to inspect degeneracy
mintripcos
Minimal triple cosine during the iterative
algorithm observed at every 10 iterations, used to inspect degeneracy
ftiter
Matrix containing in each row the function value
and the minimal triple cosine at every 10 iterations
const
Optional constraints (same as the input parameter
const
)
The argument const
should be a three element character vector.
Set const[j]="none"
for unconstrained update in j-th mode weight
matrix (the default),
const[j]="orth"
for orthogonal update in j-th mode weight matrix,
const[j]="nonneg"
for non-negative constraint on j-th mode or
const[j]="zerocor"
for zero correlation between the extracted
factors.
The default is unconstrained update for all modes.
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
.
Valentin Todorov, valentin.todorov@chello.at
Harshman, R.A. (1970). Foundations of Parafac procedure: models and conditions for an "explanatory" multi-mode factor analysis. UCLA Working Papers in Phonetics, 16: 1–84.
Harshman, R. A., & Lundy, M. E. (1994). PARAFAC: Parallel factor analysis. Computational Statistics and Data Analysis, 18, 39–72.
Lawson CL, Hanson RJ (1974). Solving Least Squares Problems. Prentice Hall, Englewood Cliffs, NJ.
## Not run:
## Example with the OECD data
data(elind)
dim(elind)
res <- cp_als(elind, ncomp=3)
res$fp
res$fp
res$iter
res <- cp_als(elind, ncomp=3, const="nonneg")
res$A
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.