The N-way toolbox FAQ

by
Rasmus Bro & Claus A. Andersson

Find the answer to common questions here

Question:

Is there a manual or tutorial for the N-way Toolbox?

Answer:

There is an on-line course on how to use the toolbox at http://www.models.kvl.dk/~pih/parafac/chap0contents.htm.

Question:

When I fit the parafac model I get an error: 

» [factors]=parafac(X,DimX,2);

??? Error using ==> gram

Too many input arguments.

Error in ==> C:\MATLABR11\toolbox\nway\dtld.m

On line 151 ==> [Bg,Cg,Ag]=gram(reshape(Gt(1,:),f,f),reshape(Gt(2,:),f,f),F);

Error in ==> C:\MATLABR11\toolbox\nway\parafac.m

On line 473 ==> [A,B,C]=dtld(X,DimX,Fac);

Answer:

You may have the PLS_toolbox as well. In that, there is also a function called GRAM. In order to avoid this error, you have to make sure that PARAFAC calls the N-way toolbox version of gram rather than the PLS_toolbox version of GRAM. One way of doing this, is to use pathtool.m for rearranging the order in which the directories are searched. Simply drag the path to the N-way toolbox so that it appears higher in the list than the PLS_toolbox does.

Question:

Centering and scaling of data is a bit strange. To center and scale column-wise I need to use "mode 1" for centering and "mode 2" for scaling.

Answer:

Yes, it seems like a strange convention, but it actually makes sense when one considers the way that higher-order arrays have to be preprocessed (see here). The thing is that centering and scaling are applied in two completely different ways, but just happen to seem alike for two-way analysis. We are so used to two-way analysis, that it is very difficult to re-think the whole issue. Centering is performed across a mode (hence from one vector, the average of that vector is subtracted), whereas scaling is performed within a mode (all elements in one slab are multiplied by the same number). OK: it is not simple, but you can contact us if you want more detailed information! You can also have a look in this theoretical paper on centering and scaling.

Question:

I can't find the data sets that are mentioned in the tutorials in the package.

Answer:

The data sets are downloaded separately from the same page where the actual toolbox is downloaded.

Question:

When I type

>[Factors]=parafac(X,Fac,Options(3)=1)

I get an error message

Answer:

You can not use inputs like that in MATLAB. You have to input the vector Options directly. You can for example write

>Options(3) = 1

This will put zeros in Options(1:2) and the toolbox will then use defaults. Then you do

>[Factors]=parafac(X,Fac,Options)

Question: Regression coefficients

I have used your toolbox to compute a N-PLS model relating a three-way array X to a Y-vector. I have seen that the B coefficients are the regression coefficients relating the scores in the Y-space to scores in the X-space (inner relation). I would like to obtain the regression coefficients of the closed form of the N-PLS model, i.e. an array of coefficients relating X to Y directly (or relating slabs of X to Y). Could you please tell me how to obtain these regression coefficients in N-PLS modelling?

Answer

The regression coefficients are possible to obtain directly from the NPLS algorithm:

[Xfactors,Yfactors,Core,B,ypred,ssx,ssy,reg] = npls(X,y,Fac);

The parameter reg is the set of regression coefficients.


If you have any more questions, suggestions or comments please feel free to mail us.

Back to the N-way Toolbox for MATLAB.