kmr: Kernel multitask regression

Description Usage Arguments Value References Examples

View source: R/kmr.R

Description

Fits a kernel multitask regression (KMR) model.

Usage

1
2
3
kmr(x, y, kx_type = c("linear", "gaussian", "precomputed"),
  kx_option = list(sigma = 1), kt_type = c("multitask", "empirical",
  "precomputed"), kt_option = list(alpha = 1, kt = NULL))

Arguments

x

Input matrix of covariates, of dimension nobs x nvars; each row is an observation vector. If a precomputed kernel is used, then x is the square Gram matrix.

y

Output matrix of responses. y should be an nobs x ntasks matrix, where each row corresponds to an observation and each column to a task.

kx_type

Kernel for observations. kx_type="linear" is the linear kernel (default). kx_type="gaussian" is the Gaussian RBF kernel with bandwidth sigma=1 by default, or any other valued is passed as an element of the kx_option list. kx_type="precomputed" assumes that the x matrix provided is the kernel Gram matrix.

kx_option

An optional list of parameters for the observation kernel, including elements such as "sigma".

kt_type

Kernel for tasks. kt_type="multitask" (default) is the multitask kernel with parameter 0 ≤ α ≤ 1, which interpolates between the Dirac kernel for α=1 (default) and the constant kernel for α=0. The parameter alpha can be passed to the kt_option list as a field alpha. kt_type="empirical" takes the empirical correlation between outputs as kernel between the tasks. kt_type="precomputed" allows to provide a precomputed kernel as a field kt in the kt_type list.

kt_option

An optional list of parameters for the task kernel, including elements such as "alpha" and "kt".

Value

An object (list) of class "kmr", which can then be used to make predictions for the different tasks on new observations.

References

Bernard, E., Jiao, Y., Scornet, E., Stoven, V., Walter, T., and Vert, J.-P. (2017). Kernel multitask regression for toxicogenetics. bioRxiv-171298.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Data
ntr <- 80
ntst <- 20
nt <- 50
p <- 20
xtrain <- matrix(rnorm(ntr*p),ntr,p)
xtest <- matrix(rnorm(ntst*p),ntst,p)
ytrain <- matrix(rnorm(ntr*nt),ntr,nt)
ytest <- matrix(rnorm(ntst*nt),ntst,nt)

# Case I: with linear kernel for x and empirical kernel for t
# Train
mo1 <- kmr(x=xtrain, y=ytrain, kx_type="linear", kt_type="empirical")
# Predict
pred1 <- predict(mo1, xtest)
# Evaluate
evalpred(pred1, ytest, "mse")

# Case II: with precomputed kernel matrices
# Kernel matrices
kxtrain <- tcrossprod(xtrain)
kxtest <- tcrossprod(xtest,xtrain)
kttrain <- cor(ytrain)
# Train
mo2 <- kmr(x=kxtrain, y=ytrain, kx_type="precomputed", 
           kt_type="precomputed", kt_option=list(kt=kttrain))
# Predict
pred2 <- predict(mo2, kxtest)
# Evaluate
evalpred(pred2, ytest, "mse")

jpvert/kmr documentation built on Aug. 16, 2017, 5:31 p.m.