Description Usage Arguments Value Examples
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.
1 2 3 4 5 6 7 |
object |
a |
... |
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. |
an updated tskrr
object
fitted with the new lambdas.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.