krr: Kernel Ridge Regression

Description Usage Arguments Details Value References See Also Examples

View source: R/krr.R

Description

Fit kernel ridge regression, i.e. reproducing kernel Hilbert space regression.

Usage

1
krr(x, y, group = NULL)

Arguments

x

a matrix of predictors.

y

a vector of response.

group

an optional vector of the same length as y which specifies the group membership. The regression model is fitted separately for each group of observations but with the same scaling factors as well as penalty amount. If omitted, a single group is assumed.

Details

krr minimizes the sum of squared loss plus a penalty term on the squared norm of the regression function. Gaussian kernel is used. Tuning parameters are chosen by minimizing the leave-one-out cross validated mean squared error. See the mathematical formulation in the reference.

Value

An object of class krr.

References

https://arxiv.org/abs/1606.01472

See Also

predict.krr

Examples

1
2
3
4
5
6
7
8
9
  x <- matrix(rnorm(200 * 10), 200, 10)
  y <- x[, 1] + x[, 2] ^ 2 + x[, 3] * x[, 4] + rnorm(200)
  obj <- krr(x, y)
  
  xnew <- matrix(rnorm(1000 * 10), 1000, 10)
  ynew <- predict(obj, xnew)

  ytrue <- xnew[, 1] + xnew[, 2] ^ 2 + xnew[, 3] * xnew[, 4]
  mean((ynew - ytrue) ^ 2)  # MSE

listdtr documentation built on March 5, 2021, 1:07 a.m.