predict.dglars: Predict Method for dgLARS Fits.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/predict.dglars.R

Description

predict.dglars is used to obtain general predictions from a dglars object.

Usage

1
2
3
4
## S3 method for class 'dglars'
predict(object, xnew, ynew, g = NULL, 
type = c("coefficients", "nnonzero", "predictors", "eta", 
"mu", "probability", "class", "deviance"), ...)

Arguments

object

fitted dglars object.

xnew

matrix of new values of the predictors at which predictions are to be made. This argument is not used for typecoefficients”, “nnonzero” and “predictors”.

ynew

vector of new values of the responce variable. This argument is used only when type ie equal to “deviance”.

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 dglars.

type

type of prediction required; see below for more details.

...

additional argument used to ensure the compatibility with the generic method function “predict”.

Value

The object returned by predict.dglars depends on type argument:

coefficients:

a named list with components “beta”, i.e., the matrix corresponding to the dgLARS solution curve, and “phi”, i.e., the sequence of Pearson estimates of the dispersion parameter;

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 xnew is not specified then the linear predictors are computed using object$X;

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 (‘logit’) and response a vector with elements 0 (failure) or 1 (success), type = "mu" and type = "probability" give the same result. If xnew is not spefified then these values are computed using object$X;

probability:

available only for ‘binomial’ family. In this case predict.dglars returns a matrix with the fitted probabilities; furthermore, if the model is specified by using the canonical link function (‘logit’) and response a vector with entries 0/1, type = "mu" and type = "probability" give the same result. If xnew is not specified then these values are computed using object$X;

class:

available only for ‘binomial’ family. In this case predict.dglars returns a matrix with the fitted class. If xnew is not specified then these values are computed using object$X otherwise xnew is used to compute the fitted probabilities;

deviance:

a vector with the scaled residual deviances.

Author(s)

Luigi Augugliaro
Maintainer: Luigi Augugliaro [email protected]

See Also

dglars and coef.dglars.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
######################
# 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)

dglars documentation built on Oct. 9, 2018, 5:04 p.m.