Als: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Alternating Least Squares computational engine for multivariate curve resolution (MCR). | Alternating Least Squares computational engine for multivariate curve resolution (MCR). | ||
===Synopsis=== | ===Synopsis=== | ||
:[c,s] = als(x,c0,options); | :[c,s] = als(x,c0,options); | ||
===Description=== | ===Description=== | ||
ALS decomposes a matrix X as CS such that X = CS + E where E is minimized in a least squares sense. | ALS decomposes a matrix X as CS such that X = CS + E where E is minimized in a least squares sense. | ||
Inputs are the matrix to be decomposed x (size m by n), and the initial guess c0. 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). | Inputs are the matrix to be decomposed x (size m by n), and the initial guess c0. 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). | ||
An optional input options is described below. | An optional input options is described below. | ||
The outputs are the estimated matrix c (m by k) and s (k by n). Usually c is a matrix of contributionss and s is a matrix of spectra. The function | The outputs are the estimated matrix c (m by k) and s (k by n). Usually c is a matrix of contributionss and s is a matrix of spectra. The function | ||
:[c,s] = als(x,c0) | :[c,s] = als(x,c0) | ||
will decompose x using an non-negatively constrained alternating least squares calculation. To include other constraints, use the options described below. | will decompose x using an non-negatively constrained alternating least squares calculation. To include other constraints, use the options described below. | ||
Note that if no non-zero equality constraints are imposed on a factor the spectra are normalized to unit length. This can lead to significant scaling differences between factors that have non-zero equality constraints and those that do not. | Note that if no non-zero equality constraints are imposed on a factor the spectra are normalized to unit length. This can lead to significant scaling differences between factors that have non-zero equality constraints and those that do not. | ||
===Options=== | ===Options=== | ||
* '''display''': [ 'off' | {'on'} ] governs level of display to command window, | * '''display''': [ 'off' | {'on'} ] governs level of display to command window, | ||
* '''plots''': [ 'none' | {'final'} ] governs level of plotting, | * '''plots''': [ 'none' | {'final'} ] governs level of plotting, | ||
* '''ccon''': [ 'none' | 'reset' | {'fastnnls'} ] non-negativity on contributionss, (fastnnls = true least-squares solution) | * '''ccon''': [ 'none' | 'reset' | {'fastnnls'} ] non-negativity on contributionss, (fastnnls = true least-squares solution) | ||
* '''scon''': [ 'none' | 'reset' | {'fastnnls'} ] non-negativity on spectra, (fastnnls = true least-squares solution) | * '''scon''': [ 'none' | 'reset' | {'fastnnls'} ] non-negativity on spectra, (fastnnls = true least-squares solution) | ||
* '''cc''': [ ] contributions equality constraints, must be a matrix with M rows and up to K columns with NaN where equality constraints are not applied and real value of the constraint where they are applied. If fewer than K columns are supplied, the missing columns will be filled in as unconstrained, | * '''cc''': [ ] contributions equality constraints, must be a matrix with M rows and up to K columns with NaN where equality constraints are not applied and real value of the constraint where they are applied. If fewer than K columns are supplied, the missing columns will be filled in as unconstrained, | ||
* '''ccwts''': [inf] a scalar value or a 1xK vector with elements corresponding to weightings on constraints (0, no constraint, 0<wt<inf imposes constraint "softly", and inf is hard constrained). If a scalar value is passed for ccwts, that value is applied for all K factors, | * '''ccwts''': [inf] a scalar value or a 1xK vector with elements corresponding to weightings on constraints (0, no constraint, 0<wt<inf imposes constraint "softly", and inf is hard constrained). If a scalar value is passed for ccwts, that value is applied for all K factors, | ||
* '''sc''': [ ] spectra equality constraints, must be a matrix with N columns and up to K rows with NaN where equality contraints are not applied and real value of the constraint where they are applied. If fewer than K rows are supplied, the missing rows will be filled in as unconstrained. | * '''sc''': [ ] spectra equality constraints, must be a matrix with N columns and up to K rows with NaN where equality contraints are not applied and real value of the constraint where they are applied. If fewer than K rows are supplied, the missing rows will be filled in as unconstrained. | ||
* '''scwts''': [inf] weighting for spectral equality constraints (see ccwts) | * '''scwts''': [inf] weighting for spectral equality constraints (see ccwts) | ||
* '''sclc''': [ ] contributions scale axis, vector with M elements otherwise 1:M is used, | * '''sclc''': [ ] contributions scale axis, vector with M elements otherwise 1:M is used, | ||
* '''scls''': [ ] spectra scale axis, vector with N elements otherwise 1:N is used, | * '''scls''': [ ] spectra scale axis, vector with N elements otherwise 1:N is used, | ||
* '''condition''': [{'none'}| 'norm' ] type of conditioning to perform on S and C before each regression step. 'norm' conditions each spectrum or contributions to its own norm. Conditioning can help stabilize the regression when factors are significantly different in magnitude. | * '''condition''': [{'none'}| 'norm' ] type of conditioning to perform on S and C before each regression step. 'norm' conditions each spectrum or contributions to its own norm. Conditioning can help stabilize the regression when factors are significantly different in magnitude. | ||
* '''tolc''': [ {1e-5} ] tolerance on non-negativity for contributionss, | * '''tolc''': [ {1e-5} ] tolerance on non-negativity for contributionss, | ||
* '''tols''': [ {1e-5} ] tolerance on non-negativity for spectra, | * '''tols''': [ {1e-5} ] tolerance on non-negativity for spectra, | ||
* '''ittol''': [ {1e-8} ] convergence tolerance, | * '''ittol''': [ {1e-8} ] convergence tolerance, | ||
* '''itmax''': [ {100} ] maximum number of iterations, | * '''itmax''': [ {100} ] maximum number of iterations, | ||
* '''timemax''': [ {3600} ] maximum time for iterations, | * '''timemax''': [ {3600} ] maximum time for iterations, | ||
* '''rankfail''': [ 'drop' |{'reset'}| 'random' | 'fail' ] how are rank deficiencies handled: | * '''rankfail''': [ 'drop' |{'reset'}| 'random' | 'fail' ] how are rank deficiencies handled: | ||
* '''drop''' - drop deficient components from model | * '''drop''' - drop deficient components from model | ||
* '''reset''' - reset deficient components to initial guess | * '''reset''' - reset deficient components to initial guess | ||
* '''random''' - replace deficient components with random vector | * '''random''' - replace deficient components with random vector | ||
* '''fail''' - stop analysis, give error | * '''fail''' - stop analysis, give error | ||
===Examples=== | ===Examples=== | ||
To decompose a matrix x without non-negativity constraints use: | To decompose a matrix x without non-negativity constraints use: | ||
:options = als('options'); | :options = als('options'); | ||
:options.ccon = 'none'; | :options.ccon = 'none'; | ||
:options.scon = 'none'; | :options.scon = 'none'; | ||
:[c,s] = als(x,c0,options); | :[c,s] = als(x,c0,options); | ||
The following shows an example of using soft-constraints on the second spectral component of a three-component solution assuming that the variable softs contains the spectrum to which component two should be constrained. | The following shows an example of using soft-constraints on the second spectral component of a three-component solution assuming that the variable softs contains the spectrum to which component two should be constrained. | ||
:[m,n] = size(x); | :[m,n] = size(x); | ||
:options = als('options'); | :options = als('options'); | ||
:options.sc = NaN\*ones(3,n); %all 3 unconstrained | :options.sc = NaN\*ones(3,n); %all 3 unconstrained | ||
:options.sc(2,:) = softs; %constrain component 2 | :options.sc(2,:) = softs; %constrain component 2 | ||
:options.scwts = 0.5; %consider as 1/2 of total signal in X | :options.scwts = 0.5; %consider as 1/2 of total signal in X | ||
:[c,s] = als(x,c0,options); | :[c,s] = als(x,c0,options); | ||
===See Also=== | ===See Also=== | ||
[[mcr]], [[parafac]], [[pca]] | [[mcr]], [[parafac]], [[pca]] |
Revision as of 14:24, 3 September 2008
Purpose
Alternating Least Squares computational engine for multivariate curve resolution (MCR).
Synopsis
- [c,s] = als(x,c0,options);
Description
ALS decomposes a matrix X as CS such that X = CS + E where E is minimized in a least squares sense.
Inputs are the matrix to be decomposed x (size m by n), and the initial guess c0. 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).
An optional input options is described below.
The outputs are the estimated matrix c (m by k) and s (k by n). Usually c is a matrix of contributionss and s is a matrix of spectra. The function
- [c,s] = als(x,c0)
will decompose x using an non-negatively constrained alternating least squares calculation. To include other constraints, use the options described below.
Note that if no non-zero equality constraints are imposed on a factor the spectra are normalized to unit length. This can lead to significant scaling differences between factors that have non-zero equality constraints and those that do not.
Options
- display: [ 'off' | {'on'} ] governs level of display to command window,
- plots: [ 'none' | {'final'} ] governs level of plotting,
- ccon: [ 'none' | 'reset' | {'fastnnls'} ] non-negativity on contributionss, (fastnnls = true least-squares solution)
- scon: [ 'none' | 'reset' | {'fastnnls'} ] non-negativity on spectra, (fastnnls = true least-squares solution)
- cc: [ ] contributions equality constraints, must be a matrix with M rows and up to K columns with NaN where equality constraints are not applied and real value of the constraint where they are applied. If fewer than K columns are supplied, the missing columns will be filled in as unconstrained,
- ccwts: [inf] a scalar value or a 1xK vector with elements corresponding to weightings on constraints (0, no constraint, 0<wt<inf imposes constraint "softly", and inf is hard constrained). If a scalar value is passed for ccwts, that value is applied for all K factors,
- sc: [ ] spectra equality constraints, must be a matrix with N columns and up to K rows with NaN where equality contraints are not applied and real value of the constraint where they are applied. If fewer than K rows are supplied, the missing rows will be filled in as unconstrained.
- scwts: [inf] weighting for spectral equality constraints (see ccwts)
- sclc: [ ] contributions scale axis, vector with M elements otherwise 1:M is used,
- scls: [ ] spectra scale axis, vector with N elements otherwise 1:N is used,
- condition: [{'none'}| 'norm' ] type of conditioning to perform on S and C before each regression step. 'norm' conditions each spectrum or contributions to its own norm. Conditioning can help stabilize the regression when factors are significantly different in magnitude.
- tolc: [ {1e-5} ] tolerance on non-negativity for contributionss,
- tols: [ {1e-5} ] tolerance on non-negativity for spectra,
- ittol: [ {1e-8} ] convergence tolerance,
- itmax: [ {100} ] maximum number of iterations,
- timemax: [ {3600} ] maximum time for iterations,
- rankfail: [ 'drop' |{'reset'}| 'random' | 'fail' ] how are rank deficiencies handled:
- drop - drop deficient components from model
- reset - reset deficient components to initial guess
- random - replace deficient components with random vector
- fail - stop analysis, give error
Examples
To decompose a matrix x without non-negativity constraints use:
- options = als('options');
- options.ccon = 'none';
- options.scon = 'none';
- [c,s] = als(x,c0,options);
The following shows an example of using soft-constraints on the second spectral component of a three-component solution assuming that the variable softs contains the spectrum to which component two should be constrained.
- [m,n] = size(x);
- options = als('options');
- options.sc = NaN\*ones(3,n); %all 3 unconstrained
- options.sc(2,:) = softs; %constrain component 2
- options.scwts = 0.5; %consider as 1/2 of total signal in X
- [c,s] = als(x,c0,options);