View source: R/predict.autotune_lasso.R
| predict.autotune_lasso | R Documentation |
Predict from a autotune_lasso fit
## S3 method for class 'autotune_lasso'
predict(
object,
newx = NULL,
type = c("response", "coefficients"),
path = NULL,
...
)
object |
An object of class |
newx |
Numeric matrix of new |
type |
Character; one of |
path |
For |
... |
Further arguments passed from the generic. |
If type = "response", returns the prediction at the x provided for prediction.
If type = "coefficients", returns the fitted coefficients.
set.seed(10)
n = 300
p = 500
s = 10
beta = c(rep(1, s), rep(0, p - s))
x = matrix(rnorm(n * p), ncol = p)
# Maunal sigma allocation
# y = x %*% beta + rnorm(n, sd = 1)
# Dynamic sigma allocation with snr specified
snr = 2
y = x %*% beta + rnorm(n, sd = sqrt(var(x%*%beta)/snr))
fit <- autotune_lasso(x, y)
predict(fit, newx = x[1:5, , drop = FALSE])
predict(fit, type = "coefficients")
predict(fit, type = "coefficients", path = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.