R: get coefficients or make coefficient predictions from a...
coef.cv.HDtweedie
R Documentation
get coefficients or make coefficient predictions from a "cv.HDtweedie" object.
Description
This function gets coefficients or makes coefficient predictions from a cross-validated HDtweedie model,
using the "cv.HDtweedie" object, and the optimal value
chosen for lambda.
Usage
## S3 method for class 'cv.HDtweedie'
coef(object,s=c("lambda.1se","lambda.min"),...)
Arguments
object
fitted cv.HDtweedie object.
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, it is the largest value of lambda such that error is
within 1 standard error of the minimum. Alternatively s="lambda.min" can be
used, it is the optimal value of lambda that gives minimum
cross validation error cvm. 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 get coefficients or make coefficient predictions.
Value
The coefficients at the requested values for lambda.
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.
Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized
linear models via coordinate descent," Journal of Statistical Software, 33, 1. http://www.jstatsoft.org/v33/i01/
See Also
cv.HDtweedie, and predict.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)
# the coefficients at lambda = lambda.1se
coef(cv0)
# 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)
# the coefficients at lambda = lambda.min
coef(cv1, s = cv1$lambda.min)
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/coef.cv.HDtweedie.Rd_%03d_medium.png", width=480, height=480)
> ### Name: coef.cv.HDtweedie
> ### Title: get coefficients or make coefficient predictions from a
> ### "cv.HDtweedie" object.
> ### Aliases: coef.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)
>
> # the coefficients at lambda = lambda.1se
> coef(cv0)
1
(Intercept) 0.422025864
CAR_TYPE_2 0.000000000
CAR_TYPE_3 0.000000000
CAR_TYPE_4 0.000000000
CAR_TYPE_5 0.000000000
CAR_TYPE_6 0.000000000
JOBCLASS_3 0.000000000
JOBCLASS_4 0.000000000
JOBCLASS_5 0.000000000
JOBCLASS_6 0.000000000
JOBCLASS_7 0.000000000
JOBCLASS_8 0.000000000
JOBCLASS_9 0.000000000
MAX_EDUC_2 0.000000000
MAX_EDUC_3 0.000000000
MAX_EDUC_4 0.000000000
MAX_EDUC_5 0.000000000
KIDSDRIV 0.000000000
KIDSDRIV2 0.000000000
KIDSDRIV3 0.000000000
TRAVTIME 0.000000000
TRAVTIME2 0.000000000
TRAVTIME3 0.000000000
BLUEBOOK 0.000000000
BLUEBOOK2 0.000000000
BLUEBOOK3 0.000000000
NPOLICY 0.000000000
NPOLICY2 0.000000000
NPOLICY3 -0.002167954
MVR_PTS 0.233435617
MVR_PTS2 0.028641844
MVR_PTS3 -0.004980527
AGE 0.000000000
AGE2 0.000000000
AGE3 0.000000000
HOMEKIDS 0.000000000
HOMEKIDS2 0.000000000
HOMEKIDS3 0.000000000
YOJ 0.000000000
YOJ2 0.000000000
YOJ3 0.000000000
INCOME 0.000000000
INCOME2 0.000000000
INCOME3 0.001372781
HOME_VAL 0.000000000
HOME_VAL2 0.000000000
HOME_VAL3 0.000000000
SAMEHOME 0.000000000
SAMEHOME2 0.000000000
SAMEHOME3 0.000000000
CAR_USE 0.000000000
RED_CAR 0.000000000
REVOLKED 1.067422551
GENDER 0.000000000
MARRIED 0.000000000
PARENT1 0.000000000
AREA 0.174949463
>
> # 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)
>
> # the coefficients at lambda = lambda.min
> coef(cv1, s = cv1$lambda.min)
1
(Intercept) 5.212698e-03
CAR_TYPE_2 0.000000e+00
CAR_TYPE_3 0.000000e+00
CAR_TYPE_4 0.000000e+00
CAR_TYPE_5 0.000000e+00
CAR_TYPE_6 0.000000e+00
JOBCLASS_3 0.000000e+00
JOBCLASS_4 0.000000e+00
JOBCLASS_5 0.000000e+00
JOBCLASS_6 0.000000e+00
JOBCLASS_7 0.000000e+00
JOBCLASS_8 0.000000e+00
JOBCLASS_9 0.000000e+00
MAX_EDUC_2 0.000000e+00
MAX_EDUC_3 0.000000e+00
MAX_EDUC_4 0.000000e+00
MAX_EDUC_5 0.000000e+00
KIDSDRIV 0.000000e+00
KIDSDRIV2 0.000000e+00
KIDSDRIV3 0.000000e+00
TRAVTIME 6.071423e-03
TRAVTIME2 -1.135608e-02
TRAVTIME3 -6.875278e-03
BLUEBOOK -6.516801e-02
BLUEBOOK2 -5.813428e-02
BLUEBOOK3 -1.081029e-02
NPOLICY 2.514255e-04
NPOLICY2 4.621700e-04
NPOLICY3 -1.781278e-03
MVR_PTS 7.603910e-02
MVR_PTS2 1.020027e-01
MVR_PTS3 -9.475828e-03
AGE 6.743328e-03
AGE2 -2.076095e-03
AGE3 4.913319e-03
HOMEKIDS -1.421894e-04
HOMEKIDS2 -2.077932e-04
HOMEKIDS3 -2.442254e-04
YOJ 0.000000e+00
YOJ2 0.000000e+00
YOJ3 0.000000e+00
INCOME -3.651765e-05
INCOME2 -1.635535e-03
INCOME3 4.789793e-03
HOME_VAL -3.808199e-02
HOME_VAL2 -9.770824e-03
HOME_VAL3 7.359830e-03
SAMEHOME -1.819713e-03
SAMEHOME2 -1.436461e-03
SAMEHOME3 -1.158754e-03
CAR_USE 5.319494e-02
RED_CAR 0.000000e+00
REVOLKED 1.363461e+00
GENDER -4.950235e-02
MARRIED 0.000000e+00
PARENT1 0.000000e+00
AREA 7.196042e-01
>
>
>
>
>
> dev.off()
null device
1
>