This function makes predictions at particular points along the fitted
glmpath.
The linear predictor, estimated response,
log-likelihood, or the coefficients can be computed.
# S3 method for glmpath
predict(object, newx, newy, s, type = c("link", "response",
"loglik", "coefficients"), mode = c("step",
"norm.fraction", "norm", "lambda.fraction", "lambda"),
weight = NULL, offset = NULL,
eps = .Machine$double.eps, ...)
a glmpath
object
a matrix of features at which the predictions are made. If
type=link,
type=response,
or type=loglik,
newx
is required.
a vector of responses corresponding to newx.
If
type=loglik,
newy
is required.
the values of mode
at which the predictions are made. If
s
is missing, then the steps at which the active set changed
are used, and thus, mode
is automatically switched to
step.
If type=link,
the linear predictors are returned; if
type=response,
the estimated responses are returned; if
type=loglik,
the log-likelihoods are returned, and if
type=coefficients,
the coefficients are returned. The
coefficients for the initial input variables are returned (rather
than the standardized coefficients). Default is link.
what mode=s
refers to. If mode=step,
s
is the
number of steps taken; if mode=norm.fraction,
s
is the
fraction of the L1 norm of the standardized coefficients (with
respect to the largest norm); if mode=norm,
s
is the
L1 norm of the standardized coefficients; if
mode=lambda.fraction,
s
is the fraction of
log(\(\lambda\)); and if mode=lambda,
s
is
\(\lambda\). Default is step.
an optional vector of weights for observations. weight
is
effective only if type=loglik.
If offset
was used in object,
offset
must be
provided for prediction, unless type=coefficients.
an effective zero
other options for the prediction
Mee Young Park and Trevor Hastie (2007) L1 regularization path algorithm for generalized linear models. J. R. Statist. Soc. B, 69, 659-677.
cv.glmpath, glmpath, plot.glmpath
# NOT RUN {
data(heart.data)
attach(heart.data)
fit <- glmpath(x, y, family=binomial)
pred <- predict(fit, x, s = seq(0, 1, length=10), mode="norm.fraction")
detach(heart.data)
# }
Run the code above in your browser using DataLab