predict.tune_xrnet: Predict function for "tune_xrnet" object

Description Usage Arguments Value Examples

View source: R/predict_tune_xrnet.R

Description

Extract coefficients or predict response in new data using fitted model from a tune_xrnet object. Note that we currently only support returning results that are in the original path(s).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'tune_xrnet'
predict(
  object,
  newdata = NULL,
  newdata_fixed = NULL,
  p = "opt",
  pext = "opt",
  type = c("response", "link", "coefficients"),
  ...
)

Arguments

object

A tune_xrnet object

newdata

matrix with new values for penalized variables

newdata_fixed

matrix with new values for unpenalized variables

p

vector of penalty values to apply to predictor variables. Default is optimal value in tune_xrnet object.

pext

vector of penalty values to apply to external data variables. Default is optimal value in tune_xrnet object.

type

type of prediction to make using the xrnet model, options include:

  • response

  • link (linear predictor)

  • coefficients

...

pass other arguments to xrnet function (if needed)

Value

The object returned is based on the value of type as follows:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(GaussianExample)

## 5-fold cross validation
cv_xrnet <- tune_xrnet(
    x = x_linear,
    y = y_linear,
    external = ext_linear,
    family = "gaussian",
    control = xrnet.control(tolerance = 1e-6)
 )

## Get coefficients and predictions at optimal penalty combination
coef_xrnet <- predict(cv_xrnet, type = "coefficients")
pred_xrnet <- predict(cv_xrnet, newdata = x_linear, type = "response")

xrnet documentation built on March 26, 2020, 9:13 p.m.