# Faq how do I use specific known pure component spectra with MCR

### Issue:

How do I use specific known pure component spectra with MCR (Multivariate Curve Resolution)?

### Possible Solutions:

MCR is a powerful technique, particularly when you can direct it with known information. One method of using the information you know to guide MCR is with estimations of underlying pure component spectra. The following describes how to perform this action using the PLS_Toolbox MCR function.

Assume that you have your data of mixtures in a variable named `data` in which samples are rows and columns are variables. Assume further that you have a single spectrum (i.e. row) which is a known pure component spectrum contributing to data (or at least an estimate of a pure component spectrum) which you have in a variable named `pure` which would be a row vector.

You can use this pure component to help guide MCR to a solution in a variety of ways.

1. Pure component as initial guess - by using your known pure spectrum as an initial guess, you are pointing MCR towards a reasonable solution. However, you must provide an initial guess for as many components as you want to resolve - even those you do not have a starting point for. One solution is to use the PLS_Toolbox `distslct` function which selects rows of your data matrix as reasonable initial guesses. We will start with the one known spectrum as component 1 and add `distslct` selected samples as the initial guesses for the other components:
2. >> k = 5; %k is total number of components you want to resolve >> c0(1,:) = pure; %first component will be pure component 1 >> iguess = distslct(data,k-1); %choose k-1 components >> c0(2:k,:) = data(iguess,:); >> model = mcr(data,c0); %do MCR with c0 as initial guess Note that the solution you get in `model` will be different from what you gave as an initial guess because MCR is allowed to change that guess to make it fit the data better. Sometimes, you may get better results if you choose initial guess samples from the part of the data which is orthogonal to pure. The following works in place of the `iguess = distslct...` line above: >> b = data - (diag(1./sum(pure.^2,2))*(pure*data'))'*pure; >> iguess = distslct(b,k-1); %choose k-1 components
3. Hard-constrained solution - hard constraints keep MCR from making any changes to one or more of the initial guesses. You can specify EXACTLY what MCR should find for a given spectrum. You will give MCR an array with NaN's in all places that you do NOT want constrained and then fill in the values you DO want constrained. Start by developing the initial guess as described above, then do the following:
4. >> sc = ones(k,n)*nan; %nothing constrained (all NaN) >> sc(1, : ) = pure; %first component MUST be pure >> opts = mcr('options'); >> opts.alsoptions.sc = sc; >> opts.alsoptions.scwts = inf; %hard constraint >> model = mcr(data,c0,opts); This will keep MCR from changing the initial guess for the first component at all.
5. Soft-constrained solution - soft constraints allow MCR to make mild to moderate changes to your initial guess. The level of "softness" is controlled by the `alsoptions.scwts` option. This is exactly as in (b) above except that you'll change the following line:
6. >> opts.alsoptions.scwts = 1; %soft constraints You can change the "1" to any number > 0. The larger the number, the harder the constraint (1 gives equal weight to both the data and the constraint).

Which model is the best?

So, which method above is the best one? Well, you should examine the sum squared residuals to identify the lowest total error. You should also consider the interpretability of the model. Finally, you should try to change the number of components you are trying to resolve as this can have a significant impact on the quality and fit of a model.