predict.l2boost {l2boost} | R Documentation |
predict method for l2boost models.
Description
predict
is a generic function for predictions from the results
of various model fitting functions.
@details predict.l2boost
takes the optional xnew (equivalent newdata) data.frame
and returns the model estimates from an l2boost
object. If neither xnew or newdata are
provided, predict
returns estimates for the l2boost
training data set.
By default, predict.l2boost
returns the function estimates, unless type="coef" then the
set of regression coefficients (beta) are returned from the l2boost
object.
Usage
## S3 method for class 'l2boost'
predict(object, xnew = NULL, type = c("fit", "coef"), newdata = xnew, ...)
Arguments
object |
an l2boost object |
xnew |
a new design matrix to fit with the l2boost object |
type |
"fit" or "coef" determins the values returned. "fit" returns model estimates, "coef" returns the model coefficients |
newdata |
a new design matrix to fit with the l2boost object |
... |
other arguments (currently not used) |
Value
function estimates for type=fit, coefficient estimates for type=coef
yhatvector of n function estimates from the final step M
yhat.pathlist of M function estimates, one at each step m
or
coefvector of p beta coefficient estimates from final step M
coef.standvector of p standardized beta coefficient estimates from final step M
coef.pathlist of vectors of p beta coefficient estimates, one for each step m
coef.stand.pathlist of vectors of p standardized beta coefficient estimates, one for each step m
See Also
predict
and l2boost
, coef.l2boost
,
fitted.l2boost
, residuals.l2boost
and cv.l2boost
Examples
#--------------------------------------------------------------------------
# Example 1: Diabetes
#
# See Efron B., Hastie T., Johnstone I., and Tibshirani R.
# Least angle regression. Ann. Statist., 32:407-499, 2004.
data(diabetes)
object <- l2boost(diabetes$x,diabetes$y, M=1000, nu=.01)
# With no arguments returns the estimates at the full M from the training data.
prd <- predict(object)
prd$yhat
# at step m=600
prd$yhat.path[[600]]
# Also can return coefficient estimates. This is equivalent to \code{\link{coef.l2boost}}
cf <- predict(object, type="coef")
cf$coef
# at step m=600
cf$coef.path[[600]]
# Or used to predict new data, in this case a subset of training data
cbind(diabetes$y[1:5], predict(object, xnew=diabetes$x[1:5,])$yhat)