Faq PARALIND in PLS Toolbox: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Lyle
imported>Lyle
No edit summary
Line 7: Line 7:
It is indeed possible to do PARALIND. PARALIND is essentially a PARAFAC model where some component matrices are constrained such that there are linear dependencies. For example, in PARALIND it may be specified that while the score matrix has five columns (five components), component one and three should be identical. Or component four should be equal to the sum of component one to three. Such constraints can be added in PARALIND and PLS_Toolbox allows to implement constraints in all modes. The following code exemplifies how it is possible to do PARALIND.  
It is indeed possible to do PARALIND. PARALIND is essentially a PARAFAC model where some component matrices are constrained such that there are linear dependencies. For example, in PARALIND it may be specified that while the score matrix has five columns (five components), component one and three should be identical. Or component four should be equal to the sum of component one to three. Such constraints can be added in PARALIND and PLS_Toolbox allows to implement constraints in all modes. The following code exemplifies how it is possible to do PARALIND.  


<pre>
% Load amino acid EEM fluorescence data as example
% Load amino acid EEM fluorescence data as example
% PARALIND is not needed for these data, so this is just an example
% PARALIND is not needed for these data, so this is just an example


load aminoacids
>>load aminoacids


% Define dependency in mode two. The actual loadings will be
% Define dependency in mode two. The actual loadings will be
% a set of three vectors multiplied by H_B
% a set of three vectors multiplied by H_B


H_B = [1 0 1;0 0 1;0 1 0]; % Dependency in mode 2
>>H_B = [1 0 1;0 0 1;0 1 0]; % Dependency in mode 2


% Likewise for mode three, but note that H_C is 2*3. Therefore,
% Likewise for mode three, but note that H_C is 2*3. Therefore,
Line 23: Line 24:
% this model
% this model


H_C = [1 0 0;0 1 1]; % dependency in mode 3
>>H_C = [1 0 0;0 1 1]; % dependency in mode 3


% Define PARAFAC to do PARALIND in two modes
% Define PARAFAC to do PARALIND in two modes


opt = parafac('options');
>>opt = parafac('options');
opt.constraints{2}.type = 'rightprod';
>>opt.constraints{2}.type = 'rightprod';
opt.constraints{3}.type = 'rightprod';
>>opt.constraints{3}.type = 'rightprod';


% Set the actual dependency matrices
% Set the actual dependency matrices


opt.constraints{2}.advanced.linearconstraints.matrix = H_B;
>>opt.constraints{2}.advanced.linearconstraints.matrix = H_B;
opt.constraints{3}.advanced.linearconstraints.matrix = H_C;
>>opt.constraints{3}.advanced.linearconstraints.matrix = H_C;


% Fit the model
% Fit the model


model = parafac(X,3,opt);
>>model = parafac(X,3,opt);


% Plot the three loadings in mode three slightly shifted
% Plot the three loadings in mode three slightly shifted
% and see that two of them are identical
% and see that two of them are identical


close
>>close
plot(model.loads{3}*diag([1 1 1.01]))
>>plot(model.loads{3}*diag([1 1 1.01];
</pre>


[[Category:FAQ]]
[[Category:FAQ]]

Revision as of 15:01, 13 November 2018

Issue:

Can I do PARALIND in PLS_Toolbox?

Possible Solutions:

It is indeed possible to do PARALIND. PARALIND is essentially a PARAFAC model where some component matrices are constrained such that there are linear dependencies. For example, in PARALIND it may be specified that while the score matrix has five columns (five components), component one and three should be identical. Or component four should be equal to the sum of component one to three. Such constraints can be added in PARALIND and PLS_Toolbox allows to implement constraints in all modes. The following code exemplifies how it is possible to do PARALIND.

% Load amino acid EEM fluorescence data as example
% PARALIND is not needed for these data, so this is just an example

>>load aminoacids

% Define dependency in mode two. The actual loadings will be
% a set of three vectors multiplied by H_B

>>H_B = [1 0 1;0 0 1;0 1 0]; % Dependency in mode 2

% Likewise for mode three, but note that H_C is 2*3. Therefore,
% mode three loadings are really defined as a two (not three) column
% matrix multiplied by H_C. In this particular case, the second
% row of H_C defines that loading two and three must be identical for
% this model

>>H_C = [1 0 0;0 1 1]; % dependency in mode 3

% Define PARAFAC to do PARALIND in two modes

>>opt = parafac('options');
>>opt.constraints{2}.type = 'rightprod';
>>opt.constraints{3}.type = 'rightprod';

% Set the actual dependency matrices

>>opt.constraints{2}.advanced.linearconstraints.matrix = H_B;
>>opt.constraints{3}.advanced.linearconstraints.matrix = H_C;

% Fit the model

>>model = parafac(X,3,opt);

% Plot the three loadings in mode three slightly shifted
% and see that two of them are identical

>>close
>>plot(model.loads{3}*diag([1 1 1.01];