Description Usage Arguments Value References Examples
This function implements groupregularized gamma regression with a known shape parameter ν and the log link. In gamma regression, we assume that y_i \sim Gamma(μ_i, ν), where
f(y_i  μ_i, ν ) = \frac{1}{Γ(ν)} (\frac{ν}{μ_i})^{ν} \exp(\frac{ν}{μ_i}y_i) y_i^{ν1}, y > 0.
Then E(y_i) = μ_i, and we relate μ_i to a set of p covariates x_i through the log link,
\log(μ_i) = β_0 + x_i^T β, i=1,..., n
If the covariates in each x_i are grouped according to known groups g=1, ..., G, then this function may estimate some of the G groups of coefficients as all zero, depending on the amount of regularization.
Our implementation for regularized gamma regression is based on the least squares approximation approach of Wang and Leng (2007), and hence, the function does not allow the total number of covariates p to be greater than sample size.
1 2 3  grpreg.gamma(y, X, X.test, groups, gamma.shape=1,
penalty=c("gLASSO","gSCAD","gMCP"),
weights, taper, nlambda=100, lambda, max.iter=10000, tol=1e4)

y 
n \times 1 vector of responses for training data. 
X 
n \times p design matrix for training data, where the jth column of 
X.test 
n_{test} \times p design matrix for test data to calculate predictions. 
groups 
pdimensional vector of group labels. The jth entry in 
gamma.shape 
known shape parameter ν in Gamma(μ_i,ν) distribution for the responses. Default is 
penalty 
group regularization method to use on the groups of coefficients. The options are 
weights 
groupspecific, nonnegative weights for the penalty. Default is to use the square roots of the group sizes. 
taper 
tapering term γ in group SCAD and group MCP controlling how rapidly the penalty tapers off. Default is 
nlambda 
number of regularization parameters L. Default is 
lambda 
grid of L regularization parameters. The user may specify either a scalar or a vector. If the user does not provide this, the program chooses the grid automatically. 
max.iter 
maximum number of iterations in the algorithm. Default is 
tol 
convergence threshold for algorithm. Default is 
The function returns a list containing the following components:
lambda 
L \times 1 vector of regularization parameters 
beta0 
L \times 1 vector of estimated intercepts. The kth entry in 
beta 
p \times L matrix of estimated regression coefficients. The kth column in 
mu.pred 
n_{test} \times L matrix of predicted mean response values μ_{test} = E(Y_{test}) based on the test data in 
classifications 
G \times L matrix of classifications, where G is the number of groups. An entry of "1" indicates that the group was classified as nonzero, and an entry of "0" indicates that the group was classified as zero. The kth column of 
loss 
L \times 1 vector of negative loglikelihood of the fitted models. The kth entry in 
Breheny, P. and Huang, J. (2015). "Group descent algorithms for nonconvex penalized linear and logistic regression models with grouped predictors." Statistics and Computing, 25:173187.
Wang, H. and Leng, C. (2007). "Unified LASSO estimation by least squares approximation." Journal of the American Statistical Association, 102:10391048.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  ## Generate data
set.seed(12345)
X = matrix(runif(100*11), nrow=100)
n = dim(X)[1]
groups = c("a","a","a","b","b","b","c","c","d","e","e")
groups = as.factor(groups)
true.beta = c(1,1,1,0,0,0,0,0,0,1.5,1.5)
## Generate responses from gamma regression with known shape parameter 1
eta = crossprod(t(X), true.beta)
shape = 1
y = rgamma(n, rate=shape/exp(eta), shape=shape)
## Generate test data
n.test = 50
X.test = matrix(runif(n.test*11), nrow=n.test)
## Fit gamma regression models with the group LASSO penalty
gamma.mod = grpreg.gamma(y, X, X.test, groups, penalty="gLASSO")
## Tuning parameters used to fit models
gamma.mod$lambda
# Predicted n.testdimensional vectors mu=E(Y.test) based on test data, X.test.
# The kth column of 'mu.pred' corresponds to the kth entry in 'lambda.'
gamma.mod$mu.pred
# Classifications of the 5 groups. The kth column of 'classifications'
# corresponds to the kth entry in 'lambda.'
gamma.mod$classifications

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.