These functions calculate either the hat matrix, the mapping matrix or the original (kernel) matrix for a two-step kernel ridge regression, based on the eigendecomposition of the kernel matrix.
eigen2hat(eigen, val, lambda)eigen2map(eigen, val, lambda)
eigen2matrix(eigen, val)
a matrix with the eigenvectors.
an numeric vector with the eigenvalues.
a single numeric value for the hyperparameter lambda
a numeric matrix representing either the hat matrix
(eigen2hat
), the map matrix (eigen2map
) or
the original matrix (eigen2matrix
)
For the hat matrix, this boils down to:
$$U\Sigma(\Sigma + \lambda I)^{-1} U^{T}$$
For the map matrix, this is :
$$U(\Sigma + \lambda I)^{-1} U^{T}$$
with \(U\) the matrix with eigenvectors, \(\Sigma\) a diagonal matrix with the eigenvalues on the diagonal, \(I\) the identity matrix and \(\lambda\) the hyperparameter linked to this kernel. The internal calculation is optimized to avoid having to invert a matrix. This is done using the fact that \(\Sigma\) is a diagonal matrix.