1.2.9 Convergence and errors🔗ℹ

Coordinate descent cycles over the coefficients until no update moves the objective by more than #:thresh (default 1e-7) times the null deviance, or until #:max-iters passes (default 100000). ols defaults to a tighter 1e-10, because the unpenalized solution is approached slowly. The pass count is recorded in every result:

> (elnet-result-num-passes (lasso X y #:lambda 0.1))

20

> (elnet-result-num-passes (lasso X y #:lambda 0.1 #:thresh 1e-12))

34

Problems are reported in three ways:

  • Before the solver runs, an argument of the wrong type, a ragged or empty matrix, a non-finite entry, or a response of the wrong length raises exn:fail:contract (see Data layout).

  • Data that glmnet cannot fit raises exn:fail with a readable message: for example when every predictor is constant, when a class probability collapses under perfect separation (a larger #:lambda usually fixes that), or when a Gaussian response is constant, as R reports too.

  • When glmnet fits no λ at all, for example because the solver hits #:max-iters before converging, the fit raises exn:fail with glmnet’s reason, naming the procedure called. R warns and returns an empty model instead. A regularization path that fails after fitting some λ keeps those and logs a warning with the topic 'glmnet, as R warns. The warning names the procedure called, and for cross-validation what it was fitting: all the data, or the training data of a held-out fold.

> (ols '((1.0 2.0) (1.0 2.0) (1.0 2.0)) '(1.0 2.0 3.0))

ols: all used predictors have zero variance

> (lasso X y #:lambda 0.01 #:max-iters 1)

lasso: glmnet fitted no lambda: convergence was not reached

at the first lambda within #:max-iters passes; try a larger

#:max-iters (jerr=-1)