how can I add a bias in lassoglm?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposte (1)
Aditya
il 14 Lug 2025
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 :
0 Commenti
Vedere anche
Categorie
Scopri di più su Generalized Linear Models in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!