Last data update: 2014.03.03

R: get coefficients or make coefficient predictions from an...
coef.HDtweedieR Documentation

get coefficients or make coefficient predictions from an "HDtweedie" object.

Description

Computes the coefficients at the requested values for lambda from a fitted HDtweedie object.

Usage

## S3 method for class 'HDtweedie'
coef(object, s = NULL, ...)

Arguments

object

fitted HDtweedie model object.

s

value(s) of the penalty parameter lambda at which predictions are required. Default is the entire sequence used to create the model.

...

not used. Other arguments to predict.

Details

s is the new vector at which predictions are requested. If s is not in the lambda sequence used for fitting the model, the coef function will use linear interpolation to make predictions. The new values are interpolated using a fraction of coefficients from both left and right lambda indices.

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.

See Also

predict.HDtweedie method

Examples

# load HDtweedie library
library(HDtweedie)

# load data set
data(auto)

# fit the lasso
m0 <- HDtweedie(x=auto$x,y=auto$y,p=1.5)

# the coefficients at lambda = 0.01
coef(m0,s=0.01)

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

# fit grouped lasso
m1 <- HDtweedie(x=auto$x,y=auto$y,group=group1,p=1.5)

# the coefficients at lambda = 0.01 and 0.04
coef(m1,s=c(0.01,0.04))

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.HDtweedie.Rd_%03d_medium.png", width=480, height=480)
> ### Name: coef.HDtweedie
> ### Title: get coefficients or make coefficient predictions from an
> ###   "HDtweedie" object.
> ### Aliases: coef.HDtweedie
> ### Keywords: models regression
> 
> ### ** Examples
> 
> # load HDtweedie library
> library(HDtweedie)
> 
> # load data set
> data(auto)
> 
> # fit the lasso
> m0 <- HDtweedie(x=auto$x,y=auto$y,p=1.5)
> 
> # the coefficients at lambda = 0.01
> coef(m0,s=0.01)
                       1
(Intercept) -0.055919922
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.022868351
TRAVTIME3    0.000000000
BLUEBOOK    -0.058530567
BLUEBOOK2   -0.022798853
BLUEBOOK3    0.000000000
NPOLICY      0.000000000
NPOLICY2     0.000000000
NPOLICY3    -0.001885975
MVR_PTS      0.290668624
MVR_PTS2     0.000000000
MVR_PTS3    -0.003345931
AGE          0.015615244
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.006162290
HOME_VAL    -0.038507332
HOME_VAL2    0.000000000
HOME_VAL3    0.000000000
SAMEHOME    -0.002501553
SAMEHOME2    0.000000000
SAMEHOME3    0.000000000
CAR_USE      0.000000000
RED_CAR      0.000000000
REVOLKED     1.313816847
GENDER      -0.009220928
MARRIED      0.000000000
PARENT1      0.000000000
AREA         0.633743866
> 
> # define group index
> group1 <- c(rep(1,5),rep(2,7),rep(3,4),rep(4:14,each=3),15:21)
> 
> # fit grouped lasso
> m1 <- HDtweedie(x=auto$x,y=auto$y,group=group1,p=1.5)
> 
> # the coefficients at lambda = 0.01 and 0.04
> coef(m1,s=c(0.01,0.04))
                        1             2
(Intercept) -0.0139344872  2.762691e-02
CAR_TYPE_2   0.0000000000  0.000000e+00
CAR_TYPE_3   0.0000000000  0.000000e+00
CAR_TYPE_4   0.0000000000  0.000000e+00
CAR_TYPE_5   0.0000000000  0.000000e+00
CAR_TYPE_6   0.0000000000  0.000000e+00
JOBCLASS_3   0.0000000000  0.000000e+00
JOBCLASS_4   0.0000000000  0.000000e+00
JOBCLASS_5   0.0000000000  0.000000e+00
JOBCLASS_6   0.0000000000  0.000000e+00
JOBCLASS_7   0.0000000000  0.000000e+00
JOBCLASS_8   0.0000000000  0.000000e+00
JOBCLASS_9   0.0000000000  0.000000e+00
MAX_EDUC_2   0.0000000000  0.000000e+00
MAX_EDUC_3   0.0000000000  0.000000e+00
MAX_EDUC_4   0.0000000000  0.000000e+00
MAX_EDUC_5   0.0000000000  0.000000e+00
KIDSDRIV     0.0000000000  0.000000e+00
KIDSDRIV2    0.0000000000  0.000000e+00
KIDSDRIV3    0.0000000000  0.000000e+00
TRAVTIME     0.0115355246  3.165135e-03
TRAVTIME2   -0.0197503791 -4.967120e-03
TRAVTIME3   -0.0087967500 -5.057641e-03
BLUEBOOK    -0.0769476264 -5.050464e-02
BLUEBOOK2   -0.0775000064 -4.497963e-02
BLUEBOOK3   -0.0143151087 -7.967835e-03
NPOLICY      0.0003483026  2.071023e-04
NPOLICY2     0.0006801757  3.157850e-04
NPOLICY3    -0.0018126902 -1.777935e-03
MVR_PTS      0.0775199095  7.451852e-02
MVR_PTS2     0.1028374463  1.013421e-01
MVR_PTS3    -0.0096263869 -9.301774e-03
AGE          0.0116242657  3.623374e-03
AGE2        -0.0037004413 -6.317712e-04
AGE3         0.0068829188  2.980813e-03
HOMEKIDS    -0.0001501087 -8.438859e-05
HOMEKIDS2   -0.0002194621 -1.499156e-04
HOMEKIDS3   -0.0002037064 -1.748394e-04
YOJ          0.0000000000  0.000000e+00
YOJ2         0.0000000000  0.000000e+00
YOJ3         0.0000000000  0.000000e+00
INCOME      -0.0001461974 -1.332826e-05
INCOME2     -0.0019271557 -1.315205e-03
INCOME3      0.0058768768  3.242854e-03
HOME_VAL    -0.0473411490 -2.811231e-02
HOME_VAL2   -0.0153580926 -5.406091e-03
HOME_VAL3    0.0121535289  3.741908e-03
SAMEHOME    -0.0042132405  0.000000e+00
SAMEHOME2   -0.0037517973 -3.480539e-04
SAMEHOME3   -0.0020591768  0.000000e+00
CAR_USE      0.0813016134  3.096446e-02
RED_CAR      0.0000000000  0.000000e+00
REVOLKED     1.3779096826  1.350769e+00
GENDER      -0.0732833392 -2.111859e-02
MARRIED     -0.0128853050  0.000000e+00
PARENT1      0.0000000000  0.000000e+00
AREA         0.7529625516  6.932212e-01
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>