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

  1. function press = pcrpress(a, c, av, cv, vc, maxrank)
  2. % PCRPRESS   Calculate PRESS as a function of the number of factors used
  3. %
  4. %  press = pcrpress(a, c, av, cv, vc, maxrank)
  5. %
  6. % Where:
  7. %
  8. %  press    is the matrix containing press
  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.  
  17. % Copyright (c) 1989-92 by The MathWorks, Inc.
  18.  
  19. [i, j] = size(vc);
  20. press(i,1)=0;
  21.  
  22. if nargin == 6, i = maxrank; end
  23.  
  24. for n = 1:i
  25.    proj = vc(:,1:n)' * a;
  26.    error = (c * proj' * inv(proj * proj') * vc(:,1:n)' * av) - cv;
  27.    press(n, 1) = sum(sum(error .* error));
  28. end
  29.