Learn R Programming

ncvreg (version 3.1-0)

ncvreg_fit: Internal C function for fitting ncvreg models

Description

This function is a wrapper for the calls to C carried out by ncvreg. This function performs no checking, processing or standardization, so use ncvreg instead, unless you really know what you're doing.

Usage

ncvreg_fit(X, y, family=c("gaussian", "binomial", "poisson"),
penalty=c("MCP", "SCAD", "lasso"), gamma=3, alpha=1, lambda, eps=.001,
max.iter=1000, dfmax=p+1, penalty.factor=rep(1, ncol(X)), warn=TRUE)

Arguments

X
The design matrix. Unlike in ncvreg, ncvreg_fit does not standardize the data. For Gaussian responses, no intercept is included. At least for now, an intercept is still included a
y
The response vector.
family
Either "gaussian", "binomial", or "poisson", depending on the response.
penalty
The penalty to be applied to the model. Either "MCP" (the default), "SCAD", or "lasso".
gamma
The tuning parameter of the MCP/SCAD penalty, as in ncvreg.
alpha
Tuning parameter which controls the relative contributions from the MCP/SCAD penalty and the ridge, or L2 penalty, as in ncvreg.
lambda
A user-specified sequence of lambda values. Unlike in ncvreg, this must be specified directly in ncvreg_fit.
eps
Convergence threshhold, as in ncvreg.
max.iter
Maximum number of iterations. Default is 1000.
dfmax
Upper bound for the number of nonzero coefficients, as in ncvreg.
penalty.factor
A multiplicative factor for the penalty applied to each coefficient, as in ncvreg.
warn
Return warning messages for failures to converge and model saturation? Default is TRUE.

Value

  • A list with components:
  • betaThe fitted matrix of coefficients. The number of rows is equal to the number of coefficients, and the number of columns is equal to the length of lambda.
  • lossA vector containing either the residual sum of squares ("gaussian") or negative log-likelihood ("binomial" or "poisson") of the fitted model at each value of lambda.
  • iterA vector of length nlambda containing the number of iterations until convergence at each value of lambda.
  • lambdaThe sequence of regularization parameter values in the path.

Details

ncvreg_fit is supplied as a separate function in case developers wish to embed ncvreg's internal algorithms in a larger procedure. It should not be called directly unless you know exactly what you are doing. In particular, no standardization or processing of X and y are carried out, and the output will not work with any of other functions in the package such as plot.ncvreg or predict.ncvreg.

References

Breheny, P. and Huang, J. (2011) Coordinate descent algorithms for nonconvex penalized regression, with applications to biological feature selection. Ann. Appl. Statist., 5: 232-253.

See Also

ncvreg

Examples

Run this code
data(prostate)
X <- as.matrix(prostate[,1:8])
y <- prostate$lpsa

## These two results are NOT the same;
## No standardization is being done in the latter
ncvreg(X, y, lambda=c(0.5, 0.1, 0.05))$beta
ncvreg_fit(X, y, lambda=c(0.5, 0.1, 0.05))$beta

Run the code above in your browser using DataLab