Fit a linear model via penalized nonconvex loss function. The regularization path is computed for the lasso (or elastic net penalty), scad (or snet) and mcp (or mnet penalty), at a grid of values for the regularization parameter lambda.
nclreg_fit(x, y, weights, offset=NULL, cost=0.5,
rfamily=c("clossR", "closs", "gloss", "qloss"),
s=NULL, fk=NULL, iter=10, del=1e-10, nlambda=100, lambda=NULL,
lambda.min.ratio=ifelse(nobs
input matrix, of dimension nobs x nvars; each row is an observation vector.
response variable. Quantitative for rfamily="clossR"
and -1/1 for classifications.
observation weights. Can be total counts if responses are proportion matrices. Default is 1 for each observation
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. Currently only one offset term can be included in the formula.
price to pay for false positive, 0 < cost
< 1; price of false negative is 1-cost
.
Response type and relevant loss functions (see above)
nonconvex loss tuning parameter for robust regression and classification.
predicted values at an iteration in the MM algorithm
The number of lambda
values - default is 100. The sequence may be truncated before nlambda
is reached if a close to saturated model is fitted. See also satu
.
by default, the algorithm provides a sequence of regularization values, or a user supplied lambda
sequence
Smallest value for lambda
, as a fraction of
lambda.max
, the (data derived) entry value (i.e. the smallest
value for which all coefficients are zero except the intercept). Note, there is no closed formula for lambda.max
. The default of lambda.min.ratio
depends on the
sample size nobs
relative to the number of variables
nvars
. If nobs > nvars
, the default is 0.001
,
close to zero. If nobs < nvars
, the default is 0.05
.
The \(L_2\) penalty mixing parameter, with
\(0<\le alpha\le 1\). alpha=1
is lasso (mcp, scad) penalty; and alpha=0
the ridge penalty. However, if alpha=0
, one must provide lambda
values.
The tuning parameter of the snet
or mnet
penalty.
logical value for x variable standardization, prior to
fitting the model sequence. The coefficients are always returned on
the original scale. Default is standardize=TRUE
.
This is a number that multiplies lambda
to allow
differential shrinkage of coefficients. Can be 0 for some variables, which implies
no shrinkage, and that variable is always included in the
model. Default is same shrinkage for all variables.
a method to determine the initial values. If type.init="ncl"
, an intercept-only model as initial parameter and run nclreg
regularization path forward from lambda_max to lambda_min. If type.init="heu"
, heuristic initial parameters and run nclreg
path backward or forward depending on direction
, between lambda_min and lambda_max. If type.init="bst"
, run a boosting model with bst
in package bst, depending on mstop.init, nu.init
and run nclreg
backward or forward depending on direction
.
an integer giving the number of boosting iterations when type.init="bst"
a small number (between 0 and 1) defining the step size or shrinkage parameter when type.init="bst"
.
only used if lambda=NULL
. direction="bwd"
for backward or "fwd" for forward, used to determine regularization path direction either from lambda_max to a potentially modified lambda_min or vice versa if type.init="bst", "heu"
.
number of iteration in the MM algorithm
Within each MM algorithm iteration, maximum number of coordinate descent iterations for each lambda
value; default is 1000.
convergency critera
If a coefficient is less than eps
in magnitude, then it is reported to be 0
Type of regularization
solution path. If type.path="active"
, then direction="bwd"
by the program. Cycle through only the active set in the next increasing lambda
sequence. If type.path="naive"
, no active set for each element of the lambda sequence, iterate until convergency. If type.path="onestep"
, update for one element of lambda depending on direction="fwd" (last element of lambda) or "bwd" (then first element of lambda) in each MM iteration, and iterate until convergency of prediction. Then fit a solution path based on the sequence of lambda.
If TRUE
, fitting progress is reported
An object with S3 class "nclreg"
for the various types of models.
the call that produced the model fit
Intercept sequence of length length(lambda)
A nvars x length(lambda)
matrix of coefficients.
The actual sequence of lambda
values used
The sequence of robust models implied by lambda
is fit by majorization-minimization along with coordinate
descent. Note that the objective function is $$1/2*weights*loss + \lambda*penalty,$$ if standardize=FALSE
and $$1/2*
\frac{weights}{\sum(weights)}*loss + \lambda*penalty,$$ if standardize=TRUE
.