2
$\begingroup$

In the blog post here it states that the diagonal of the hat matrix

H = X inv(X'X) X'

for a linear regression can be used to quickly calculate the leave one out cross validation error of the regression fit. To check if this is this only true for an unregularised linear fit I used the Octave code below

clear all
lambda = input( 'Enter lambda: ' ) ;
% data
y = rand(20,1) ;
X = [ ones(20,1) rand(20,5) ] ;
w = ( inv( X' * X + lambda * eye(size(X'*X)) ) * X' ) * y ;
y_fit = X * w ;
H = X * inv( X' * X + lambda * eye(size(X'*X)) ) * X' ;
yh_fit = H * y ;
both_fits = [ y_fit yh_fit ]
plot( y , 'b', y_fit , 'r' , yh_fit , 'g' )

to calculate a regularised linear fit and using the calculation

H = X * inv( X' * X + lambda * I ) * X' ;

for the hat matrix H, where lambda is the regularisation coefficient and I the identity matrix. Given that the numerical results, i.e. the y_fit using the weights and the yh_fit using the hat matrix, are the same, can I safely assume that the LOOCV statistic for a regularised fit can be calculated in the same way as outlined in the above linked blog post.

$\endgroup$

1 Answer 1

1
$\begingroup$

The Tikhonov regularized version of this is

$H=X(X^{T}X+\lambda I)^{-1}X^{T}$.

$\endgroup$
2
  • $\begingroup$ You added your answer while I was editing my question $\endgroup$ Commented Feb 23, 2015 at 0:09
  • $\begingroup$ Yes, but perhaps adding (L2-norm) or "Ridge regression") after "Tikhonov" in yr answer would help search engines reference yr perfectly fine answer better. Cheers. $\endgroup$
    – Cbhihe
    Commented Jun 8, 2018 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.