home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 6.ddi / CHEM.DI$ / PCRFITV.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.0 KB  |  31 lines

  1. function fitv = pcrfitv(a, c, av, cv, vc, maxrank)
  2. % PCRFITV  Calculate the fit to a validation set with given eigenvectors.
  3. %
  4. %  fitv = pcrfitv(a, c, av, cv, vc, maxrank)
  5. %
  6. % Where:
  7. %
  8. %  fit      is the matrix containing information on the fit
  9. %  a        is the training set absorbance matrix
  10. %  c        is the training set concentration matrix
  11. %  av       is the validation set absorbance matrix
  12. %  cv       is the validation set concentration matrix
  13. %  vc       is the matrix containing the eigenvectors (factors)
  14. %  maxrank  is optional limit to the number of factors tested
  15. %
  16. % The first columns of fitv contain the std's of the fit for each
  17. % component.  The last column contains the mean for all components.
  18. %
  19.  
  20. % Copyright (c) 1989-92 by The MathWorks, Inc.
  21.  
  22. [i, j] = size(vc);
  23. [k, l] = size(c);
  24. fitv(i, (k + 1)) = 0;
  25. if nargin == 6, i = maxrank; end
  26. for n = 1:i;
  27.    proj = vc(:,1:n)' * a;
  28.    error = (c * proj' * inv(proj * proj') * vc(:,1:n)' * av) - cv;
  29. fitv(n, :) = [std(error') mean(std(error'))];
  30. end
  31.