Home > NoiseTools > nt_regcov.m

nt_regcov

PURPOSE ^

r=nt_regcov(cxy,cyy,keep,threshold) - regression matrix from cross covariance

SYNOPSIS ^

function r=nt_regcov(cxy,cyy,keep,threshold)

DESCRIPTION ^

r=nt_regcov(cxy,cyy,keep,threshold) - regression matrix from cross covariance

  r: matrix to apply to regressor to best model data

  cxy: cross-covariance matrix between data and regressor
  cyy: covariance matrix of regressor
  keep: number of regressor PCs to keep (default: all)
  threshold: eigenvalue threshold for discarding regressor PCs (default: 0)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function r=nt_regcov(cxy,cyy,keep,threshold)
0002 %r=nt_regcov(cxy,cyy,keep,threshold) - regression matrix from cross covariance
0003 %
0004 %  r: matrix to apply to regressor to best model data
0005 %
0006 %  cxy: cross-covariance matrix between data and regressor
0007 %  cyy: covariance matrix of regressor
0008 %  keep: number of regressor PCs to keep (default: all)
0009 %  threshold: eigenvalue threshold for discarding regressor PCs (default: 0)
0010 
0011 if nargin<4; threshold=[]; end
0012 if nargin<3; keep=[]; end
0013 if nargin<2; error('!'); end
0014 
0015 % PCA of regressor
0016 [topcs,eigenvalues]=nt_pcarot(cyy);
0017 
0018 % discard negligible regressor PCs
0019 if ~isempty(keep)
0020     keep=max(keep,size(topcs,2));
0021     topcs=topcs(:,1:keep);
0022     eigenvalues=eigenvalues(1:keep);
0023 end
0024 if ~isempty(threshold)
0025     idx=find(eigenvalues/max(eigenvalues)>threshold);
0026     topcs=topcs(:,idx);
0027     eigenvalues=eigenvalues(idx);
0028 end
0029 
0030 % cross-covariance between data and regressor PCs
0031 cxy=cxy';
0032 r=topcs'*cxy;
0033 
0034 % projection matrix from regressor PCs
0035 r=nt_vecmult(r,1./eigenvalues');
0036 
0037 % projection matrix from regressors
0038 r=topcs*r;
0039 
0040 return
0041 
0042 
0043 
0044

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005