Modelstruct: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
(Importing text file)
 
imported>Jeremy
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===Purpose===
===Purpose===
Constructs an empty model structure.
Constructs an empty model structure.
===Synopsis===
===Synopsis===
:model = modelstruct(modeltype,pred)
:model = modelstruct(modeltype,pred)
===Description===
===Description===
The output of many of the PLS_Toolbox functions is a single model structure in which the results of the analysis are contained. A structure is an organized group of variables all stored as "fields" of a single containing variable. The purpose of MODELSTRUCT is to create the empty model structures used by the various modeling routines. The type of structure requested is passed as the single string input modeltype and should be one of: 'pca', 'pcr', (for PCA or PCR models) 'nip', 'sim' (PLS models), or 'parafac' (PARAFAC model).
 
The output of many of the PLS_Toolbox functions is a single model structure in which the results of the analysis are contained. A structure is an organized group of variables all stored as "fields" of a single containing variable.  
 
For information on the contents of a model structure, see the advanced topics page [[Standard_Model_Structure]].
 
The purpose of MODELSTRUCT is to create the empty model structures used by the various modeling routines. The type of structure requested is passed as the single string input modeltype and should be one of the supported model types.
 
Once the structures created by MODELSTRUCT are filled-in by the appropriate function (e.g. PLS, PCR, PCA), they contain all the results of the analysis and can be used as a single object for making further predictions or plots from the modeling results. In many cases, these models can be passed whole to another function. For example:
Once the structures created by MODELSTRUCT are filled-in by the appropriate function (e.g. PLS, PCR, PCA), they contain all the results of the analysis and can be used as a single object for making further predictions or plots from the modeling results. In many cases, these models can be passed whole to another function. For example:
:opts.plots = 'none';      % turn off plots for PCA (see PCA)
 
:modl = pca(x, 3, opts);  % create a PCA model from data X
<pre>opts.plots = 'none';      % turn off plots for PCA (see PCA)
:modlrder(modl);          % display relevent model information
modl = pca(x, 3, opts);  % create a PCA model from data X
:plotscores(modl);        % plot scores from model
modlrder(modl);          % display relevent model information
plotscores(modl);        % plot scores from model</pre>
 
Although the individual fields (contents) of each model vary between modeltypes, most contain at least these fields:
Although the individual fields (contents) of each model vary between modeltypes, most contain at least these fields:
* modeltype: name of model,
 
* datasource: structure array with information about input data,
* '''modeltype''': name of model,
* date: date of creation,
 
* time: time of creation,
* '''datasource''': structure array with information about input data,
* info: additional model information,
 
* loads: cell array with model loadings for each mode/dimension,
* '''date''': date of creation,
* pred: cell array with model predictions for input data block (the first cell is empty if options.blockdetail = 'normal'),
 
* tsqs: cell array with T<sup>2</sup> values for each mode,
* '''time''': time of creation,
* ssqresiduals: cell array with sum of squares residuals for each mode,
 
* description: cell array with text description of model, and
* '''info''': additional model information,
* detail: sub-structure with additional model details and results.
 
Note that fields such as loads, tsqs and ssqresiduals are cell arrays of size [modes, blocks] where modes is the dimensionality of the data (e.g. for an array, modes = 2) and blocks is the number of blocks used by the analysis method (e.g. for PCA, blocks = 1, for PLS, blocks = 2). Thus, for a standard PCA model, loads will be a 2x1 cell containing "scores" in modl.loads{1,1} and traditional "loadings" in modl.loads{2,1}.
* '''loads''': cell array with model loadings for each mode/dimension,
 
* '''pred''': cell array with model predictions for input data block (the first cell is empty if options.blockdetail = 'normal'),
 
* '''tsqs''': cell array with T<sup>2</sup> values for each mode,
 
* '''ssqresiduals''': cell array with sum of squares residuals for each mode,
 
* '''description''': cell array with text description of model, and
 
* '''detail''': sub-structure with additional model details and results.
 
Note that fields such as loads, tsqs and ssqresiduals are cell arrays of size <tt>[modes, blocks]</tt> where modes is the dimensionality of the data (e.g. for an array, modes = 2) and blocks is the number of blocks used by the analysis method (e.g. for PCA, blocks = 1, for PLS, blocks = 2). Thus, for a standard PCA model, loads will be a 2x1 cell containing "scores" in <tt>modl.loads{1,1}</tt> and traditional "loadings" in <tt>modl.loads{2,1}</tt>.
 
Because the models are standard MATLAB structures, they can be examined using standard structure notation:
Because the models are standard MATLAB structures, they can be examined using standard structure notation:
:>> modl.modeltype
 
:ans =
<pre>>> modl.modeltype
:PCA
ans =
:>> modl.loads
PCA
:ans =  
>> modl.loads
:    [30x4 double]
ans =  
:    [10x4 double]
    [30x4 double]
    [10x4 double]</pre>
 
Additionally, the individual components of a model can be "exploded" into individual variables using the EXPLODE function.
Additionally, the individual components of a model can be "exploded" into individual variables using the EXPLODE function.
Read more about model structures here: [[Standard_Model_Structure]]
===See Also===
===See Also===
[[analysis]], [[explode]], [[parafac]], [[pca]], [[pcr]], [[pls]]
[[analysis]], [[explode]], [[parafac]], [[pca]], [[pcr]], [[pls]]

Latest revision as of 12:06, 19 February 2010

Purpose

Constructs an empty model structure.

Synopsis

model = modelstruct(modeltype,pred)

Description

The output of many of the PLS_Toolbox functions is a single model structure in which the results of the analysis are contained. A structure is an organized group of variables all stored as "fields" of a single containing variable.

For information on the contents of a model structure, see the advanced topics page Standard_Model_Structure.

The purpose of MODELSTRUCT is to create the empty model structures used by the various modeling routines. The type of structure requested is passed as the single string input modeltype and should be one of the supported model types.

Once the structures created by MODELSTRUCT are filled-in by the appropriate function (e.g. PLS, PCR, PCA), they contain all the results of the analysis and can be used as a single object for making further predictions or plots from the modeling results. In many cases, these models can be passed whole to another function. For example:

opts.plots = 'none';      % turn off plots for PCA (see PCA)
modl = pca(x, 3, opts);   % create a PCA model from data X
modlrder(modl);           % display relevent model information
plotscores(modl);         % plot scores from model

Although the individual fields (contents) of each model vary between modeltypes, most contain at least these fields:

  • modeltype: name of model,
  • datasource: structure array with information about input data,
  • date: date of creation,
  • time: time of creation,
  • info: additional model information,
  • loads: cell array with model loadings for each mode/dimension,
  • pred: cell array with model predictions for input data block (the first cell is empty if options.blockdetail = 'normal'),
  • tsqs: cell array with T2 values for each mode,
  • ssqresiduals: cell array with sum of squares residuals for each mode,
  • description: cell array with text description of model, and
  • detail: sub-structure with additional model details and results.

Note that fields such as loads, tsqs and ssqresiduals are cell arrays of size [modes, blocks] where modes is the dimensionality of the data (e.g. for an array, modes = 2) and blocks is the number of blocks used by the analysis method (e.g. for PCA, blocks = 1, for PLS, blocks = 2). Thus, for a standard PCA model, loads will be a 2x1 cell containing "scores" in modl.loads{1,1} and traditional "loadings" in modl.loads{2,1}.

Because the models are standard MATLAB structures, they can be examined using standard structure notation:

>> modl.modeltype
ans =
PCA
>> modl.loads
ans = 
    [30x4 double]
    [10x4 double]

Additionally, the individual components of a model can be "exploded" into individual variables using the EXPLODE function.

Read more about model structures here: Standard_Model_Structure

See Also

analysis, explode, parafac, pca, pcr, pls