Last data update: 2014.03.03

R: make predictions from a "cv.HDtweedie" object.
predict.cv.HDtweedieR Documentation

make predictions from a "cv.HDtweedie" object.

Description

This function makes predictions from a cross-validated HDtweedie model, using the stored "cv.HDtweedie" object, and the optimal value chosen for lambda.

Usage

## S3 method for class 'cv.HDtweedie'
predict(object, newx, s=c("lambda.1se","lambda.min"),...)

Arguments

object

fitted cv.HDtweedie object.

newx

matrix of new values for x at which predictions are to be made. Must be a matrix. See documentation for predict.HDtweedie.

s

value(s) of the penalty parameter lambda at which predictions are required. Default is the value s="lambda.1se" stored on the CV object. Alternatively s="lambda.min" can be used. If s is numeric, it is taken as the value(s) of lambda to be used.

...

not used. Other arguments to predict.

Details

This function makes it easier to use the results of cross-validation to make a prediction.

Value

The returned object depends on the ... argument which is passed on to the predict method for HDtweedie objects.

Author(s)

Wei Qian, Yi Yang and Hui Zou
Maintainer: Wei Qian <weiqian@stat.umn.edu>

References

Qian, W., Yang, Y., Yang, Y. and Zou, H. (2013), “Tweedie's Compound Poisson Model With Grouped Elastic Net,” submitted to Journal of Computational and Graphical Statistics.

See Also

cv.HDtweedie, and coef.cv.HDtweedie methods.

Examples

# load HDtweedie library
library(HDtweedie)

# load data set
data(auto)

# 5-fold cross validation using the lasso
cv0 <- cv.HDtweedie(x=auto$x,y=auto$y,p=1.5,nfolds=5) 

# predicted mean response at lambda = lambda.1se, newx = x[1,]
pre = predict(cv0, newx = auto$x[1,], type = "response")

# define group index
group1 <- c(rep(1,5),rep(2,7),rep(3,4),rep(4:14,each=3),15:21)

# 5-fold cross validation using the grouped lasso 
cv1 <- cv.HDtweedie(x=auto$x,y=auto$y,group=group1,p=1.5,nfolds=5)

# predicted the log mean response at lambda = lambda.min, x[1:5,]
pre = predict(cv1, newx = auto$x[1:5,], s = cv1$lambda.min, type = "link")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HDtweedie)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HDtweedie/predict.cv.HDtweedie.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.cv.HDtweedie
> ### Title: make predictions from a "cv.HDtweedie" object.
> ### Aliases: predict.cv.HDtweedie
> ### Keywords: models regression
> 
> ### ** Examples
> 
> # load HDtweedie library
> library(HDtweedie)
> 
> # load data set
> data(auto)
> 
> # 5-fold cross validation using the lasso
> cv0 <- cv.HDtweedie(x=auto$x,y=auto$y,p=1.5,nfolds=5) 
> 
> # predicted mean response at lambda = lambda.1se, newx = x[1,]
> pre = predict(cv0, newx = auto$x[1,], type = "response")
> 
> # define group index
> group1 <- c(rep(1,5),rep(2,7),rep(3,4),rep(4:14,each=3),15:21)
> 
> # 5-fold cross validation using the grouped lasso 
> cv1 <- cv.HDtweedie(x=auto$x,y=auto$y,group=group1,p=1.5,nfolds=5)
> 
> # predicted the log mean response at lambda = lambda.min, x[1:5,]
> pre = predict(cv1, newx = auto$x[1:5,], s = cv1$lambda.min, type = "link")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>