# Mpca

### Purpose

Multi-way (unfold) principal components analysis.

### Synopsis

- model = mpca(mwa,ncomp,
*options*) - model = mpca(mwa,ncomp,preprostring)
- pred = mpca(mwa,model,
*options*) - mpca - Launches an analysis window with MPCA as the selected method.

Please note that the recommended way to build and apply a MPCA model from the command line is to use the Model Object. Please see this wiki page on building and applying models using the Model Object.

### Description

Principal Components Analysis of multi-way data using unfolding to a 2-way matrix followed by conventional PCA.

Inputs to MPCA are the multi-way array mwa (class "double" or "dataset") and the number of components to use in the model nocomp. To make predictions with new data the inputs are the multi-way array mwa and the MPCA model model. Optional input *options* is discussed below.

For assistance in preparing batch data for use in MPCA please see bspcgui.

The output model is a structure array with the following fields:

**modeltype**: 'MPCA',

**datasource**: structure array with information about the x-block,

**date**: date of creation,

**time**: time of creation,

**info**: additional model information,

**loads**: 1 by 2 cell array with model loadings for each mode/dimension,

**pred**: cell array with model predictions for each input data block (this is empty if options.blockdetail = 'normal'),

**tsqs**: cell array with T^{2}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.

### Options

**options** = a structure array with the following fields.

**display**: [ 'off' | {'on'} ] governs level of display to command window,

**plots**: [ 'none' | {'final'} ] governs level of plotting,

**outputversion**: [ 2 | {3} ] governs output format,

**preprocessing**: { [] } preprocessing structure, {default is mean centering i.e. options.preprocessing = preprocess('default', 'mean center')} (see PREPROCESS),

**algorithm**: [ {'svd'} | 'maf' | 'robustpca' ], algorithm for decomposition, Algorithm 'maf' requires Eigenvector's MIA_Toolbox.

**confidencelimit**: [ {'0.95'} ], confidence level for Q and T2 limits. A value of zero (0) disables calculation of confidencelimits.

**roptions**: structure of options to pass to robpca (robust PCA engine from the Libra Toolbox).

**blockdetails**: [ 'compact' | {'standard'} | 'all' ] level of detail (predictions, raw residuals, and calibration data) included in the model.

- ‘Standard’ = the predictions and raw residuals for the X-block as well as the X-block itself are not stored in the model to reduce its size in memory. Specifically, these fields in the model object are left empty: 'model.pred{1}', 'model.detail.res{1}', 'model.detail.data{1}'.
- ‘Compact’ = for this function, 'compact' is identical to 'standard'.
- 'All' = keep predictions, raw residuals for X-blocks as well as the X-blocks dataset itself.

**samplemode**: [ {3} ] mode (dimension) to use as the sample mode e.g. if it is 3 then it is assumed that mode 3 is the sample/object dimension i.e. if mwa is 7x9x10 then the scores model.loads{1} will have 10 rows (it will be 10xncomp).

The default options can be retreived using: options = mpca('options');.

It is also possible to input just the preprocessing option as an ordinary string in place of *options* and have the remainder of options filled in with the defaults from above. The following strings are valid:

- '
**none'**: no scaling,

- '
**auto'**: unfolds array then applies autoscaling,

- '
**mncn'**: unfolds array then applies mean centering, or

- '
**grps'**: {default} unfolds array then group/block scales each variable, i.e. the same variance scaling is used for each variable along its time trajectory (see GSCALE).

MPCA will work with arrays of order 3 and higher. For higher order arrays, the last order is assumed to be the sample order, *i.e.* for an array of order *n* with the dimension of order *n* being *m*, the unfolded matrix will have *m* samples. For arrays of higher order the group scaling option will group together all data with the same order 2 index, for multiway array mwa, each mwa(:,j,:, ... ,:) will be scaled as a group.

### See Also

analysis, bspcgui, evolvfa, ewfa, explode, npls, parafac, parafac2, pca, preprocess, EVRIModel_Objects