# statsmodels.regression.linear_model.GLS.fit_regularized¶

GLS.fit_regularized(method='elastic_net', alpha=0.0, L1_wt=1.0, start_params=None, profile_scale=False, refit=False, **kwargs)[source]

Return a regularized fit to a linear regression model.

Parameters
methodstr

Either ‘elastic_net’ or ‘sqrt_lasso’.

alpha

The penalty weight. If a scalar, the same penalty weight applies to all variables in the model. If a vector, it must have the same length as params, and contains a penalty weight for each coefficient.

L1_wtscalar

The fraction of the penalty given to the L1 penalty term. Must be between 0 and 1 (inclusive). If 0, the fit is a ridge fit, if 1 it is a lasso fit.

start_paramsarray_like

Starting values for params.

profile_scalebool

If True the penalized fit is computed using the profile (concentrated) log-likelihood for the Gaussian model. Otherwise the fit uses the residual sum of squares.

refitbool

If True, the model is refit using only the variables that have non-zero coefficients in the regularized fit. The refitted model is not regularized.

**kwargs

Additional keyword arguments that contain information used when constructing a model using the formula interface.

Returns
statsmodels.base.elastic_net.RegularizedResults

The regularized results.

Notes

The elastic net uses a combination of L1 and L2 penalties. The implementation closely follows the glmnet package in R.

The function that is minimized is:

$0.5*RSS/n + alpha*((1-L1\_wt)*|params|_2^2/2 + L1\_wt*|params|_1)$

where RSS is the usual regression sum of squares, n is the sample size, and $$|*|_1$$ and $$|*|_2$$ are the L1 and L2 norms.

For WLS and GLS, the RSS is calculated using the whitened endog and exog data.

Post-estimation results are based on the same data used to select variables, hence may be subject to overfitting biases.

The elastic_net method uses the following keyword arguments:

maxiterint

Maximum number of iterations

cnvrg_tolfloat

Convergence threshold for line searches

zero_tolfloat

Coefficients below this threshold are treated as zero.

The square root lasso approach is a variation of the Lasso that is largely self-tuning (the optimal tuning parameter does not depend on the standard deviation of the regression errors). If the errors are Gaussian, the tuning parameter can be taken to be

alpha = 1.1 * np.sqrt(n) * norm.ppf(1 - 0.05 / (2 * p))

where n is the sample size and p is the number of predictors.

The square root lasso uses the following keyword arguments:

zero_tolfloat

Coefficients below this threshold are treated as zero.

The cvxopt module is required to estimate model using the square root lasso.

References

*

Friedman, Hastie, Tibshirani (2008). Regularization paths for generalized linear models via coordinate descent. Journal of Statistical Software 33(1), 1-22 Feb 2010.

A Belloni, V Chernozhukov, L Wang (2011). Square-root Lasso: pivotal recovery of sparse signals via conic programming. Biometrika 98(4), 791-806. https://arxiv.org/pdf/1009.5689.pdf
{"ft_lang_label":"__label__en","ft_lang_prob":0.6893673,"math_prob":0.9688643,"size":3050,"snap":"2020-45-2020-50","text_gpt3_token_len":777,"char_repetition_ratio":0.10242941,"word_repetition_ratio":0.035476718,"special_character_ratio":0.24196722,"punctuation_ratio":0.1384892,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9976162,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-28T00:43:29Z\",\"WARC-Record-ID\":\"<urn:uuid:c3e76d44-ada6-4f21-9ee5-314821a69573>\",\"Content-Length\":\"25794\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e615a063-10d5-4f35-ab09-e34dba69e93e>\",\"WARC-Concurrent-To\":\"<urn:uuid:952be771-e877-42bc-8a48-d64d4109748c>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://www.statsmodels.org/devel/generated/statsmodels.regression.linear_model.GLS.fit_regularized.html\",\"WARC-Payload-Digest\":\"sha1:BQJLOXBXE7GBF4EHYG55CK2ZLPDCYF63\",\"WARC-Block-Digest\":\"sha1:5MTQQ3DHHXSQRM3RB3MKKNRTMSJX5YZN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107894890.32_warc_CC-MAIN-20201027225224-20201028015224-00364.warc.gz\"}"}