Learn R Programming

rqPen (version 4.1.3)

predict.rq.pen.seq: Predictions from rq.pen.seq object

Description

Predictions from rq.pen.seq object

Usage

# S3 method for rq.pen.seq
predict(
  object,
  newx,
  tau = NULL,
  a = NULL,
  lambda = NULL,
  modelsIndex = NULL,
  lambdaIndex = NULL,
  sort = FALSE,
  ...
)

Value

A matrix of predictions for each tau and a combination

Arguments

object

rq.pen.seq object

newx

Matrix of predictors

tau

Quantile of interest. Default is NULL, which will return all quantiles. Should not be specified if modelsIndex is used.

a

Tuning parameter of a. Default is NULL, which returns coefficients for all values of a. Should not be specified if modelsIndex is used.

lambda

Tuning parameter of \(\lambda\). Default is NULL, which returns coefficients for all values of \(\lambda\).

modelsIndex

Index of the models for which coefficients should be returned. Does not need to be specified if tau or a are specified.

lambdaIndex

Index of the lambda values for which coefficients should be returned. Does not need to be specified if lambda is specified.

sort

If there are crossing quantiles the predictions will be sorted to avoid this issue.

...

Additional parameters passed to coef.rq.pen.seq()

Author

Ben Sherwood, ben.sherwood@ku.edu

Examples

Run this code
x <- matrix(runif(800),ncol=8)
y <- 1 + x[,1] + x[,8] + (1+.5*x[,3])*rnorm(100)
m1 <- rq.pen(x,y,penalty="ENet",a=c(0,.5,1),tau=c(.25,.75),lambda=c(.1,.05,.01))
newx <- matrix(runif(80),ncol=8)
allCoefs <- predict(m1,newx)
targetCoefs <- predict(m1,newx,tau=.25,a=.5,lambda=.1)
idxApproach <- predict(m1,newx,modelsIndex=2)
bothIdxApproach <- predict(m1,newx,modelsIndex=2,lambdaIndex=1)

Run the code above in your browser using DataLab