Description Usage Arguments Value Examples
Makes predictions from a fitted 'asgl' object.
1 2 3 |
object |
Fitted |
newx |
Matrix of new values for |
s |
Value(s) of the penalty tuning parameter at which predictions are to be made. Default is the entire sequence used to fit the regularization path. |
type |
Type of predicted required. For |
... |
Ignored. |
A matrix of predictions or, if s
is of length 1, a vector of
predictions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # linear regression
n <- 500; p <- 20; groupsize <- 5
index <- ceiling(1:p / groupsize)
beta <- (-2:2)
x <- matrix(rnorm(n * p), ncol = p, nrow = n)
y <- as.vector(x[,1:5] %*% beta + 0.1 * rnorm(n))
fit1 <- asgl(x, y, index, family = "gaussian")
predict(fit1, x)
# logistic regression
eta <- x[, 1:5] %*% beta
prob <- exp(eta) / (1 + exp(eta))
y <- rbinom(n, 1, prob)
fit2 <- asgl(x, y, index, family = "binomial")
predict(fit2, x, s = fit2$lambda[20], type = "response")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.