View source: R/predict.dglars.R
predict.dglars | R Documentation |
predict.dglars
is used to obtain general predictions from a dglars
object.
## S3 method for class 'dglars'
predict(object, xnew, ynew, g = NULL,
type = c("coefficients", "nnonzero", "predictors", "eta",
"mu", "probability", "class", "deviance"), ...)
object |
fitted |
xnew |
matrix of new values of the predictors at which predictions are to be made. This argument is not used for |
ynew |
vector of new values of the responce variable. This argument is used only when |
g |
value(s) of the tuning parameter |
type |
type of prediction required; see below for more details. |
... |
additional argument used to ensure the compatibility with the generic method function “ |
The object returned by predict.dglars
depends on type
argument:
coefficients : |
a named list with components “ |
nnonzero : |
the number of nonzero estimates; |
predictors : |
a named list; each component is a vector containing the indices of the variables that are in the active set; |
eta : |
a matrix with the linear preditors. If |
mu : |
a matrix with the fitted expeted values, obtained by transforming the linear predictor by the inverse of the link function. For models with ‘binomial’ family, canonical link function (‘ |
probability : |
available only for ‘ |
class : |
available only for ‘ |
deviance : |
a vector with the scaled residual deviances. |
Luigi Augugliaro
Maintainer: Luigi Augugliaro luigi.augugliaro@unipa.it
dglars
and coef.dglars
.
######################
# Logistic regression model
set.seed(123)
n <- 100
p <- 10
X <- matrix(rnorm(n * p), n, p)
Xnew <- matrix(rnorm(n * p), n, p)
b <- 1:2
eta <- b[1] + X[, 1] * b[2]
mu <- binomial()$linkinv(eta)
y <- rbinom(n, 1, mu)
fit <- dglars.fit(X, y, binomial)
coef(fit)
predict(fit, type = "coefficients")
g <- seq(3, 1, by = -0.1)
coef(fit, g = g)
predict(fit, type = "coefficients", g = g)
predict(fit, type = "nnonzero")
predict(fit, type = "nnonzero", g = g)
predict(fit, type = "predictors")
predict(fit, type = "predictors", g = g)
predict(fit, type = "eta", g = g)
predict(fit, type = "eta", g = g, xnew = Xnew)
predict(fit, type = "mu", g = g)
predict(fit, type = "mu", g = g, xnew = Xnew)
predict(fit, type = "probability", g = g)
predict(fit, type = "probability", g = g, xnew = Xnew)
predict(fit, type = "class", g = g)
predict(fit, type = "class", g = g, xnew = Xnew)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.