www.pudn.com > gcv.rar > gcvfctn.m


function G = gcvfctn(h, s2, fc, rss0, dof0) 
%GCVFCTN    Evaluate generalized cross-validation function. 
% 
%    gcvfctn(h, s2, fc, rss0, dof0) is the value of the GCV function 
%    for ridge regression with regularization parameter h. The other 
%    input arguments are the squared singular values s2 of the design 
%    matrix; the coefficients fc = U(:, 1:q)'*g, where U is the matrix 
%    of left singular vectors, g is a vector of response variables, 
%    and q = min(n,p) is the smaller of the numbers of rows and 
%    columns of the design matrix; the residual sum of squares of 
%    the (non-regularized) least squares estimate; and the number 
%    of residual degrees of freedom of the (non-regularized) least 
%    squares estimate. 
% 
%    Auxiliary function for GCV. 
 
%    Adapted from GCVFUN in Per-Christian Hansen's Regularization 
%    Toolbox. 
 
  f      = h^2 ./ (s2 + h^2); 
  G      = (norm(f.*fc)^2 + rss0) / (dof0 + sum(f))^2;