how can I add a bias in lassoglm?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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 :
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Generalized Linear Models についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!