predict.HDtweedie: make predictions from a "HDtweedie" object.

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

View source: R/tools.R

Description

Similar to other predict methods, this functions predicts fitted values from a HDtweedie object.

Usage

1
2
3
## S3 method for class 'HDtweedie'
predict(object, newx, s = NULL,
type=c("response","link"), ...)

Arguments

object

fitted HDtweedie model object.

newx

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

s

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

type

type of prediction required:

  • Type "response" gives the mean response estimate.

  • Type "link" gives the estimate for log mean response.

...

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 predict function will use linear interpolation to make predictions. The new values are interpolated using a fraction of predicted values from both left and right lambda indices.

Value

The object returned depends on type.

Author(s)

Wei Qian, Yi Yang and Hui Zou
Maintainer: Wei Qian <[email protected]>

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

coef method

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# load HDtweedie library
library(HDtweedie)

# load auto data set
data(auto)

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

# predicted mean response at x[10,]
print(predict(m0,type="response",newx=auto$x[10,]))

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

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

# predicted the log mean response at x[1:5,]
print(predict(m1,type="link",newx=auto$x[1:5,]))

emeryyi/hdtweedie documentation built on May 13, 2017, 5:12 p.m.