predict.hqreg: Model predictions based on "hqreg" object.

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/predict.hqreg.R

Description

This function returns fitted values, coefficients and more from a fitted "hqreg" object.

Usage

1
2
3
4
5
## S3 method for class 'hqreg'
predict(object, X, lambda, type = c("response","coefficients","nvars"), 
    exact = FALSE, ...)
## S3 method for class 'hqreg'
coef(object, lambda, exact = FALSE, ...)

Arguments

object

Fitted "hqreg" model object.

X

Matrix of values at which predictions are to be made. Used only for type = "response".

lambda

Values of the regularization parameter lambda at which predictions are requested. Default is the entire sequence used to create the model.

type

Type of prediction. "response" returns the fitted values; "coefficients" returns the coefficients; "nvars" returns the number of nonzero coefficients at each value of lambda.

exact

If exact=FALSE (default), then the function uses linear interpolation to make predictions for values of lambda that do not coincide with those used to fit the model. If exact=TRUE, and predictions are requested at values of lambda not included in the original fit, the model is refit on a lambda sequence consisting object$lambda and the new ones before predictions are made.

...

Not used. Other arguments to predict.

Value

The object returned depends on type.

Author(s)

Congrui Yi <congrui-yi@uiowa.edu>

References

Yi, C. and Huang, J. (2016) Semismooth Newton Coordinate Descent Algorithm for Elastic-Net Penalized Huber Loss Regression and Quantile Regression, https://arxiv.org/abs/1509.02957
Journal of Computational and Graphical Statistics, accepted in Nov 2016
http://www.tandfonline.com/doi/full/10.1080/10618600.2016.1256816

See Also

hqreg

Examples

1
2
3
4
5
6
7
8
9
X = matrix(rnorm(1000*100), 1000, 100)
beta = rnorm(10)
eps = 4*rnorm(1000)
y = drop(X[,1:10] %*% beta + eps) 
fit = hqreg(X, y, method = "quantile", tau = 0.7)
predict(fit, X[1:5,], lambda = c(0.05, 0.01))
predict(fit, X[1:5,], lambda = 0.05, exact = TRUE)
predict(fit, X[1:5,], lambda = 0.05, type = "nvars")
coef(fit, lambda = 0.05)

Example output

           0.05      0.01
[1,]  1.1166606 1.2705861
[2,]  2.9077826 3.0808499
[3,] -0.4005082 1.4805521
[4,]  2.8778619 0.6135273
[5,]  1.4662662 1.2473302
           [,1]
[1,]  1.1150700
[2,]  2.9123061
[3,] -0.4064723
[4,]  2.8891804
[5,]  1.4795960
[1] 6
(Intercept)          V1          V2          V3          V4          V5 
 2.18624724 -0.07611291  0.00000000  0.00000000  0.33441087  0.16157550 
         V6          V7          V8          V9         V10         V11 
 0.00000000 -0.19399620  1.28507607  1.28503301  0.00000000  0.00000000 
        V12         V13         V14         V15         V16         V17 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V18         V19         V20         V21         V22         V23 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V24         V25         V26         V27         V28         V29 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V30         V31         V32         V33         V34         V35 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V36         V37         V38         V39         V40         V41 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V42         V43         V44         V45         V46         V47 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V48         V49         V50         V51         V52         V53 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V54         V55         V56         V57         V58         V59 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V60         V61         V62         V63         V64         V65 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V66         V67         V68         V69         V70         V71 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V72         V73         V74         V75         V76         V77 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V78         V79         V80         V81         V82         V83 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V84         V85         V86         V87         V88         V89 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V90         V91         V92         V93         V94         V95 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 
        V96         V97         V98         V99        V100 
 0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 

hqreg documentation built on May 1, 2019, 10:21 p.m.