predict.dglars {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 g at which the predictions are required. By default, the predictions are made using the sequence of g values storaged in |
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:
|
a named list with components “ |
|
the number of nonzero estimates; |
|
a named list; each component is a vector containing the indices of the variables that are in the active set; |
|
a matrix with the linear preditors. If |
|
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 (‘ |
|
available only for ‘ |
|
available only for ‘ |
|
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)