gcvplot.m 699 B

12345678910111213141516171819202122232425
  1. function g=gcvplot(alpha,varargin)
  2. %
  3. % Computes and plots the Generalized Cross-Validation score (GCV)
  4. % for local fits with different smoothing parameters.
  5. %
  6. % The first argument to gcvplot(), alpha, should be a matrix with one
  7. % or two columns (first column = nearest neighbor component, second
  8. % column = constant component). Each row of this matrix is, in turn,
  9. % passed as the 'alpha' argument to gcv() (and locfit()). The results
  10. % are stored in a matrix, and GCV score ploted against the degrees of
  11. % freedom.
  12. k = size(alpha,1);
  13. z = zeros(k,4);
  14. for i=1:k
  15. z(i,:) = gcv(varargin{:},'alpha',alpha(i,:));
  16. end;
  17. plot(z(:,3),z(:,4));
  18. xlabel('Fitted DF');
  19. ylabel('GCV');
  20. g = [alpha z];
  21. return;