4.1.6.1.1. statsmodels.base.l1_solvers_common.do_trim_params

statsmodels.base.l1_solvers_common.do_trim_params(params, k_params, alpha, score, passed, trim_mode, size_trim_tol, auto_trim_tol)[source]

Trims (set to zero) params that are zero at the theoretical minimum. Uses heuristics to account for the solver not actually finding the minimum.

In all cases, if alpha[i] == 0, then don’t trim the ith param. In all cases, do nothing with the added variables.

Parameters:

params : np.ndarray

model parameters. Not including added variables.

k_params : Int

Number of parameters

alpha : np.ndarray

regularization coefficients

score : Function.

score(params) should return a 1-d vector of derivatives of the unpenalized objective function.

passed : Boolean

True if the QC check passed

trim_mode : ‘auto, ‘size’, or ‘off’

If not ‘off’, trim (set to zero) parameters that would have been zero

if the solver reached the theoretical minimum.

If ‘auto’, trim params using the Theory above. If ‘size’, trim params if they have very small absolute value

size_trim_tol : float or ‘auto’ (default = ‘auto’)

For use when trim_mode === ‘size’

auto_trim_tol : float

For sue when trim_mode == ‘auto’. Use

qc_tol : float

Print warning and don’t allow auto trim when (ii) in “Theory” (above) is violated by this much.

Returns:

params : np.ndarray

Trimmed model parameters

trimmed : np.ndarray of Booleans

trimmed[i] == True if the ith parameter was trimmed.