Polytransform: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Donal
imported>Donal
Line 38: Line 38:
===Examples===
===Examples===


If x is a 50 by 5 matrix or dataset and options are default, except for the squares option:
If x is a 10 by 4 matrix or dataset and options are default, except for the squares option:
<pre>
<pre>
m = 10; n = 4;
m = 10; n = 4;
Line 47: Line 47:
[xout, model] = polytransform(x,popts);
[xout, model] = polytransform(x,popts);
</pre>  
</pre>  
gives the 50 by 10 matrix where the columns 6 to 10 are the squares of the first five columns.
gives the 10 by 8 matrix where the columns 5 to 8 are the squares of the first four columns.


x equals xout.data(:,1:5), and xout.data(:,1:5).^2 equals xout.data(:,6:10)
x equals xout.data(:,1:4), and xout.data(:,1:4).^2 equals xout.data(:,5:8)


===See Also===
===See Also===

Revision as of 16:09, 27 September 2010

Purpose

Add new variables to a dataset object or matrix formed as power transforms and cross terms of the original variables.

Synopsis

[xout, model] = polytransform(x, options);
[xout] = polytransform(x, model);

Description

Add polynomial and cross terms to data matrix or dataset. Input dataset x has new transformed variables added. These can include existing variables raised to second, third, fourth power, or second order product of variables. The data can be preprocessed before transformed variables are calculated. preprocessingtype option specifies the type of preprocessing to apply, 'none', 'mncn', 'auto', or 'custom'. If 'custom' is specified then the 'preprocessing' option must be a valid preprocessing structure. If pca = 'on' the data are converted to PCA scores after preprocessing, but before the transformed variables are calculated.

Inputs

  • x = Dataset or matrix to be augmented by the addition of transformed variables.

Outputs

  • xout = The augmented dataset or matrix.
  • model = A standard model structure with modeltype = polytransform. This model can be used to augment new data in the same way as the original data was augmented, using the same options, including preprocessing.

Options

options is a structure array with the following fields:

  • squares: [ 'on' | {'off'} ], governs level of display,
  • cubes: [ 'on' | {'off'} ], governs level of display,
  • quadratics: [ 'on' | {'off'} ], governs level of display,
  • crossterms: [ 'on' | {'off'} ], governs level of display,
  • preprocessingtype: ['none' | 'mncn' | {'auto'} | 'pcrtile' | 'custom'], governs data preprocessing behavior,
  • preprocessing: A preprocessing structure which is used if preprocessingtype = custom,
  • pca: [ 'on' | {'off'} ], governs whether PCA is applied to the preprocessed data before transformed terms are calculated,
  • maxpcs: Integer indicating how many PCs to use if pca = on,
  • preprocessoriginalvars: [ 0| {1} ], governs whether the original variables are returned preprocessed or raw.

Examples

If x is a 10 by 4 matrix or dataset and options are default, except for the squares option:

m = 10; n = 4;
x = rand(m,n);
popts = polytransform('options');
popts.squares = 'on';
popts.preprocessingtype = 'none';
[xout, model] = polytransform(x,popts);

gives the 10 by 8 matrix where the columns 5 to 8 are the squares of the first four columns.

x equals xout.data(:,1:4), and xout.data(:,1:4).^2 equals xout.data(:,5:8)

See Also