# CPrunsFit: Candecomp/Parafac solutions In ThreeWay: Three-Way Component Analysis

## Description

Computes all the Candecomp/Parafac solutions (CP) with `r` (from 1 to `maxC`) components.

## Usage

 `1` ``` CPrunsFit(X, n, m, p, maxC) ```

## 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 `maxC` Maximum dimensionality for the `A`-mode

## Value

 `out` Matrix with columns: number of components for the `A`-mode, number of components for the `B`-mode, number of components for the `C`-mode, goodness of fit (%), total number of components

## Note

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.

## 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

H.A.L. Kiers (1991). Hierarchical relations among three-way methods. Psychometrika 56:449–470.

`DimSelector`, `LineCon`, `CP`
 ```1 2 3 4 5 6 7``` ```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) ```