Cov cv: Difference between revisions
imported>Donal No edit summary |
imported>Donal |
||
Line 49: | Line 49: | ||
algorithm = 3: results.alpha = ac*ones(1,length(S)) ; | algorithm = 3: results.alpha = ac*ones(1,length(S)) ; | ||
* '''preprocessing''': { [1] } Controls preprocessing. | |||
Two methods can be used to control preprocessing. | |||
1) For typical preprocessing methods use a scalar: | |||
0 = none, { 1 = mean centering, default }, or 2 = autoscaling. | |||
2) For more varieties of preprocessing enter a cell array options.preprocessing = {pre} where pre is a standard preprocessing structure output by PREPROCESS. | |||
* '''calccov''': [ 'no' | {'yes'} ], 'yes'. | |||
If 'yes', it is assumed that the covariance matrix must first be calculated before estimating the inverse. | |||
If 'no', it is assumed that input (x) is already a covariance and the calculation is not performed. If 'no' options.preprocessing is set to 0. | |||
===Example=== | ===Example=== |
Revision as of 16:41, 2 September 2010
Purpose
Estimation of a regularized inverse covariance matrix.
For (x) M by N, COV_CV estimates a regularized inverse of x'*x/(M-1).
If [V,S] = svd(x'*x/(M-1)), and S = diag(S); then the regularized inverse takes the form V*diag(1./(S+alpha))*V'.
The 1 by N vector alpha is output in (results.alpha) [see options.algorithm].
Synopsis
- [ccov,results] = cov_cv(x,options);
Inputs
- x = X-block class "double" or "dataset".
Optional Inputs
- options = structure array with the following fields discussed below.
Outputs
- ccov = the regularized (inverse and/or sqrt) covariance.
- results = a structure array with the following fields
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.
- condmax: {1e4} maximum regularization (condmax>1). This is the maximum condition number for (ccov).
- inverse: [ {'yes'} | 'no' ] If set to 'yes' {default} the inverse covariance matrix is estimated. If set to 'no' the output (ccov) is a regularized covariance matrix.
- sqrt: [ {'no'} | 'yes' ], governs if the output is sqrt of the cov.
- algorithm: [ 2 ], regularization method where ac = S(1)/options.condmax
algorithm = 1: results.alpha = (ac./(ac+S))*ac ;
algorithm = 2: results.alpha = (ac^2./(ac^2+S.^2))*ac ;
algorithm = 3: results.alpha = ac*ones(1,length(S)) ;
- preprocessing: { [1] } Controls preprocessing.
Two methods can be used to control preprocessing.
1) For typical preprocessing methods use a scalar: 0 = none, { 1 = mean centering, default }, or 2 = autoscaling.
2) For more varieties of preprocessing enter a cell array options.preprocessing = {pre} where pre is a standard preprocessing structure output by PREPROCESS.
- calccov: [ 'no' | {'yes'} ], 'yes'.
If 'yes', it is assumed that the covariance matrix must first be calculated before estimating the inverse.
If 'no', it is assumed that input (x) is already a covariance and the calculation is not performed. If 'no' options.preprocessing is set to 0.
Example
load nir_data [ccov,results] = cov_cv(spec1); axis([0 50 1e-8 1]), vline(results.ncomp), hline(results.s(1)/results.options.condmax) title(['nir_data: 30x401 ',get(get(gca,'title'),'string')],'interpreter','none'), figfont