# Mcr

### Purpose

Multivariate curve resolution with constraints.

### Synopsis

- model = mcr(x,ncomp,
*options*) %calibrate - model = mcr(x,c0,
*options*) %calibrate with explict initial guess - pred = mcr(x,model,
*options*) %predict - mcr % Launches an Analysis window with mcr as the selected method.

Please note that the recommended way to build and apply a MCR 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

MCR decomposes a matrix **X** as **CS** such that **X** = **CS** + **E** where **E** is minimized in a least squares sense. By default, this is done using the alternating least squares (ALS) algorithm. For details on the ALS algorithm and constraints available in MCR, see the als reference page.

When called with new data and a model structure, MCR performs a prediction (applies the model to the new data) returning the projection of the new data onto the previously recovered loadings (i.e. estimated spectra).

In addition to the constraints and options listed in als, other pages which may be of interest include MCR Constraints which describes setting constraints in the [Analysis] interface, and MCR Contrast Constraint which discusses the contrast constraint option.

#### Inputs

**x**= the matrix to be decomposed (size*m*by*n*)**ncomp**or**c0**or**model**:**ncomp**= the number of components to extract**c0**= the explicit initial guess where, if c0 is size*m*by*k*, where*k*is the number of factors, then it is assumed to be the initial guess for**C**. If c0 is size*k*by*n*then it is assumed to be the initial guess for**S**. If*m*=*n*then, c0 is assumed to be the initial guess for**C**. Optional input*options*is described below.**model**= a previously calculated MCR model structure to apply to the data in input**x**.

#### Outputs

**model**= a standard model structure containing the results of the analysis. The estimated contributions**C**are stored in model.loads{2} and the estimated spectra**S**in model.loads{1}. Sum-squared residuals for samples and variables can be found in model.ssqresiduals{1} and model.ssqresiduals{2}, respectively. See the chemometrics tutorial for more information on the MCR method and models. Note that the sum-squared captured table contains various statistics on the information captured by each component. Please see MCR and PARAFAC Variance Captured for details.

### Options

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

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

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

**waitbar**: [ 'off' | 'on' | {'auto'} ] governs use of waitbar,

**preprocessing**: { [] } preprocessing to apply to x-block (see PREPROCESS).

**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.

**initmode**: [1 | 2] Mode of x for automatic initialization.

**confidencelimit**: [{0.95}] Confidence level for Q limits.

**alsoptions**: ['options'] options passed to ALS subroutine (see ALS).

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

### See Also

als, als_sit, analysis, evolvfa, ewfa, fasternnls, fastnnls, fastnnls_sel, mlpca, parafac, parafac2, plotloads, preprocess, EVRIModel_Objects