Description Usage Arguments Details Value See Also Examples
This function makes predictions from a cross-validated sail model, using the stored "sail.fit" object, and the optimal value chosen for lambda.
1 2 3 4 5 6 |
object |
fitted |
newx |
matrix of new values for |
newe |
vector of new values for the exposure variable |
s |
Value(s) of the penalty parameter |
... |
other arguments passed to |
This function makes it easier to use the results of cross-validation to make a prediction.
The object returned depends the ... argument which is passed on to
the predict method for sail
objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | data("sailsim")
f.basis <- function(i) splines::bs(i, degree = 3)
library(doParallel)
cl <- makeCluster(2)
registerDoParallel(cl)
cvfit <- cv.sail(x = sailsim$x, y = sailsim$y, e = sailsim$e,
parallel = TRUE, nlambda = 10,
maxit = 20, basis = f.basis,
nfolds = 3, dfmax = 5)
stopCluster(cl)
predict(cvfit) # predict at "lambda.1se"
predict(cvfit, s = "lambda.min") # predict at "lambda.min"
predict(cvfit, s = 0.5) # predict at specific value of lambda
predict(cvfit, type = "nonzero") # non-zero coefficients at lambda.1se
# predict response for new data set
newx <- sailsim$x * 1.10
newe <- sailsim$e * 2
predict(cvfit, newx = newx, newe = newe, s = "lambda.min")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.