Description Usage Arguments Value References Examples
This function implements K-fold cross-validation for group-regularized negative binomial regression with a known size parameter α and the log link. For a description of group-regularized negative binomial regression, see the description for the grpreg.nb
function.
Our implementation 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 \frac{K-1}{K} \times sample size, where K is the number of folds.
1 2 3 | cv.grpreg.nb(y, X, groups, nb.size=1, penalty=c("gLASSO","gSCAD","gMCP"),
nfolds=10, weights, taper, nlambda=100, lambda, max.iter=10000,
tol=1e-4)
|
y |
n \times 1 vector of responses. |
X |
n \times p design matrix, where the jth column of |
groups |
p-dimensional vector of group labels. The jth entry in |
nb.size |
known size parameter α in NB(α,μ_i) distribution for the responses. Default is |
penalty |
group regularization method to use on the groups of coefficients. The options are |
nfolds |
number of folds K to use in K-fold cross-validation. Default is |
weights |
group-specific, 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 |
cve |
L \times 1 vector of mean cross-validation error across all K folds. The kth entry in |
cvse |
L \times 1 vector of standard errors for cross-validation error across all K folds. The kth entry in |
lambda.min |
value of |
Breheny, P. and Huang, J. (2015). "Group descent algorithms for nonconvex penalized linear and logistic regression models with grouped predictors." Statistics and Computing, 25:173-187.
Wang, H. and Leng, C. (2007). "Unified LASSO estimation by least squares approximation." Journal of the American Statistical Association, 102:1039-1048.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Generate data
set.seed(1234)
X = matrix(runif(100*16), nrow=100)
n = dim(X)[1]
groups = c(1,1,1,2,2,2,2,3,4,5,5,6,7,8,8,8)
true.beta = c(-2,2,2,0,0,0,0,0,0,1.5,-1.5,0,0,-2,2,2)
## Generate count responses from negative binomial regression
eta = crossprod(t(X), true.beta)
y = rnbinom(n,size=1, mu=exp(eta))
## 10-fold cross-validation for group-regularized negative binomial
## regression with the group SCAD penalty
nb.cv = cv.grpreg.nb(y,X,groups,penalty="gMCP")
## Plot cross-validation curve
plot(nb.cv$lambda, nb.cv$cve, type="l", xlab="lambda", ylab="CVE")
## lambda which minimizes mean CVE
nb.cv$lambda.min
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.