BookmarkSubscribeRSS Feed
lovedeep
Calcite | Level 5

Hi,

I was just wondering if there is any way to use LASSO & ELASTIC NET in logistic regression model using SAS.

Any help or suggestions will be much appreciated.

Lovedeep

9 REPLIES 9
SteveDenham
Jade | Level 19

Look into PROC GLMSELECT.  You may need to transform your dependent variable onto the logit scale before fitting.

Steve Denham

lovedeep
Calcite | Level 5

Thanks Steve,

But can you please guide me for the best way to accomplish it.

Thanks

SteveDenham
Jade | Level 19

Get your data into the events/trials syntax, if it is not already.  Apply a logit transform to the dependent variable, and run GLMSELECT with the LASSO option.

Steve Denham

RobF
Quartz | Level 8

Lasso variable selection is available for logistic regression in the latest version of the HPGENSELECT procedure (SAS/STAT 13.1 included in Base SAS 9.4).

Elastic net isn't supported quite yet. However if you're interested I can send you my Base SAS coding solution for lasso + elastic net for logistic and Poisson regression which I just presented at the 2015 SAS Global Forum.

Haris
Lapis Lazuli | Level 10

Found it.  Thanks!  I will give it a try.

http://support.sas.com/resources/papers/proceedings15/3297-2015.pdf

Google also found another suggestion for use of GLMSELECT.  Code dichotomous outcome as +-1, run GLMSELECT and apply cutoff > 0.  Will give that a try as well.

Thanks,

Haris

RobF
Quartz | Level 8

You're welcome, let me know if you have questions about the program.

The code will generate & output logistic regression coefficient estimates for selected values of the alpha & lambda parameters, but I haven't yet written code that selects the optimal alpha & lambda values for the elastic net model. You could do this using 5 or 10-fold cross validation, or else randomly split your data into two chunks, training and validation. Fit the elastic net  models for varying alpha & lambda values with the training data, then score the validation dataset with the output model coefficients & compare predictive accuracy.

I haven't tried the GLMSELECT shortcut using +1/-1 but would be interested to see how it performs.

Robert

akanujia44
Calcite | Level 5

Hi All,

 

When you say ' apply cutoff > 0 ' is something which I have not followed as to what needs to be done. Can anyone throw more light on this, like any sample code or any more information?

 

Thank you for your help and time.

FionaCao
Calcite | Level 5

Hello Robert,

I also need to use LASSO in logistic regression model in SAS and my SAS version doesn't have HPGENSELECT procedure. Could you mind sending me the link of your Base SAS coding solution for lasso for logistic and Poisson regression  presented at the 2015 SAS Global Forum?

Thank you very much and I appreciate your help!

Fiona

paoloeusebi0
Calcite | Level 5


0

 

I did run a lasso logistic regression with SAS glmselect (Y=1 for event and Y=-1 for non event). My syntax is something like:

 

proc glmselect data=<dataset> plots=all seed=123;
output out=preds pred=individual;
partition role=selected(train='1' test='0');
class Y AGE SEX;
model Y = AGE SEX AGE*SEX /selection=lasso(choose=cv stop=none) cvmethod=random(10);
run;


Everything works fine but I end-up with coefficients like that

SEXFemale*AGEYounger -0.9
SEXFemale*AGEOlder -0.7


Should I subtract -0.7 from -0.9 to find the relative effect of Younger age in the interaction with Sex? 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 17119 views
  • 4 likes
  • 7 in conversation