update: Update a tskrr object with a new lambda

Description Usage Arguments Value Examples

Description

This function allows you to refit a tskrr with a new lambda. It can be used to do manual tuning/cross-validation. If the object has the hat matrices stored, these are updated as well.

Usage

1
2
3
4
5
6
7
update(object, ...)

## S4 method for signature 'tskrrHomogeneous'
update(object, lambda)

## S4 method for signature 'tskrrHeterogeneous'
update(object, lambda)

Arguments

object

a tskrr object

...

arguments passed to methods

lambda

a numeric vector with one or two values for the hyperparameter lambda. If two values are given, the first one is used for the k matrix and the second for the g matrix.

Value

an updated tskrr object fitted with the new lambdas.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
data(drugtarget)

mod <- tskrr(drugTargetInteraction, targetSim, drugSim)

# Update with the same lambda
mod2 <- update(mod, lambda = 1e-3)

# Use different lambda for rows and columns
mod3 <- update(mod, lambda = c(0.01,0.001))

# A model with the hat matrices stored
lambda <- c(0.001,0.01)
modkeep <- tskrr(drugTargetInteraction, targetSim, drugSim, keep = TRUE)
Hk_1 <- hat(modkeep, which = "row")
modkeep2 <- update(modkeep, lambda = lambda)
Hk_2 <- hat(modkeep2, which = "row")

# Calculate new hat matrix by hand:
decomp <- get_eigen(modkeep, which = "row")
Hk_byhand <- eigen2hat(decomp$vectors,
                       decomp$values,
                       lambda = lambda[1])
identical(Hk_2, Hk_byhand)

xnet documentation built on Feb. 4, 2020, 9:10 a.m.