how can I add a bias in lassoglm?

5 次查看(过去 30 天)
Debora
Debora 2017-6-29
回答: Aditya 2025-7-14
I am fitting data with a lot predictors (between 150 and 200) and a high dergree of colinearity between the predictors. Initially I used [par,~,stat] = glmfit(dX, y,'poisson','constant','on') which works well up to about 100 predictors but then the beta start to be unreasonably small and big. So now I try to use lassoglm trying to keep the beta small by giving it a single lambda (of 0.001 or so). But where can I set the bias (or constant) and where will I see the beta for the it after the fit?

回答(1 个)

Aditya
Aditya 2025-7-14
Hi Debora,
When you use lassoglm in MATLAB , the intercept (bias/constant) is handled automatically; you do not set it manually.The coefficients for predictors are returned in the output B.The intercept is returned separately in FitInfo.Intercept.By default, lassoglm always fits an intercept unless you specify 'Intercept',false.
Example:
% Fit a Poisson GLM with Lasso regularization and a fixed lambda
[B, FitInfo] = lassoglm(dX, y, 'poisson', 'Lambda', 0.001);
% B contains the coefficients for your predictors (excluding the intercept)
% FitInfo.Intercept contains the intercept (bias/constant) term
% To get the full set of coefficients including the intercept:
fullBeta = [FitInfo.Intercept; B];
% To make predictions on new data (dXnew):
yhat = glmval([FitInfo.Intercept; B], dXnew, FitInfo.Link);
Following are the documentation links that you can refer to :

类别

Help CenterFile Exchange 中查找有关 Generalized Linear Models 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by