For each number of components, a model of the data is obtained (M1, M2 M3).
The fit of a model is equivalent to the sum of squares of residuals.
From the data and the model the fit may thus be obtained.
However, if there are missing values in the data these should be ignored in calculating the fit of the model.
In the PARAFAC algorithm,
the fit is automatically given as an extra output. Instead of using the I/O
Factors = parafac(X,3);
[Factors,it,err] = parafac(X,3);
The additional outputs are
it, which is the number of iterations used and
which is the fit-value.
The fit-value is in fact the objective function of PARAFAC; hence the algorithm seeks the model that produces the best least-squares approximation of the data.