Modelstruct: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Scott |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Line 14: | Line 13: | ||
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: | ||
<pre>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</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: | ||
Line 46: | Line 42: | ||
* '''detail''': sub-structure with additional model details and results. | * '''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}. | 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: | ||
<pre>>> modl.modeltype | |||
ans = | |||
PCA | |||
>> modl.loads | |||
ans = | |||
[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. |
Revision as of 15:37, 7 October 2008
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. 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).
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.