<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Elastic Net selection with interaction effects in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Elastic-Net-selection-with-interaction-effects/m-p/707687#M217317</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a healthcare investigator and am looking to have a model I am trying to make include interaction terms. My only problem is that when I include the interaction effects into the MODEL statement, I sometimes will get the interaction effects without the main effects in the model. I want to know how I might be able to keep the main effects in the model along with an interaction effect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro elasticnet (l2_cust_low, l2_cust_high);
ods select CoefficientPanel ASEPlot ParameterEstimates FitStatistics;
proc glmselect data=data.resilience3 plots=all seed=712;
title1 "SELECTION=ELASTICNET(L2SEARCH=GOLDEN L2LOW= &amp;amp;l2_cust_low L2HIGH= &amp;amp;l2_cust_high))";
title2 "Primary Analysis";
partition fraction(test=0.3);
class 	sex(ref='0') nonhisp_black(ref='0') nonhisp_white(ref='0') hispanic(ref='0') Married(ref='0') single(ref='0')
		ged_hsdiploma(ref='0') Assoc_Bachelor(ref='0') graduate(ref='0') Tetra_abc(ref='0') para_abc(ref='0')
		sleep(ref='0') pain_interfere2(ref='0') Healthsts_pos(ref='0') fyear_1(ref='0') fyear_5(ref='0') fyear_10(ref='0') 
		fyear_15(ref='0') fyear_20_25(ref='0') fyear_30plus(ref='0');
model BRsTScr2 = age sex nonhisp_black nonhisp_white hispanic Married single  
					ged_hsdiploma Assoc_Bachelor graduate Tetra_abc para_abc
					fyear_5 fyear_10 fyear_15 fyear_20_25 fyear_30plus
					BSFBMTS2 BSFSCTS2 BSFFMoTS2 sleep pain pain_interfere2 Healthsts_pos 
					BCHPITot2 BCHMbTot2 BCHOpTot2 BCHSocIn2 depression life_sat pain*depression / 
					SELECTION=ELASTICNET(L2SEARCH=GOLDEN L2LOW= &amp;amp;l2_cust_low L2HIGH= &amp;amp;l2_cust_high choose = cv) 
					cvmethod=split(10) hierarchy=none showpvalues;
					
run;
%MEND elasticnet;

%elasticnet(0,0.1);
%elasticnet(0.1,0.2);
%elasticnet(0.2,0.3);
%elasticnet(0.3,0.4);
%elasticnet(0.4,0.5);
%elasticnet(0.5,0.6);
%elasticnet(0.6,0.7);
%elasticnet(0.7,0.8);
%elasticnet(0.8,0.9);
%elasticnet(0.9,1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any and all help will be greatly appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 22 Dec 2020 15:44:19 GMT</pubDate>
    <dc:creator>delgaa07</dc:creator>
    <dc:date>2020-12-22T15:44:19Z</dc:date>
    <item>
      <title>Elastic Net selection with interaction effects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Elastic-Net-selection-with-interaction-effects/m-p/707687#M217317</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a healthcare investigator and am looking to have a model I am trying to make include interaction terms. My only problem is that when I include the interaction effects into the MODEL statement, I sometimes will get the interaction effects without the main effects in the model. I want to know how I might be able to keep the main effects in the model along with an interaction effect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro elasticnet (l2_cust_low, l2_cust_high);
ods select CoefficientPanel ASEPlot ParameterEstimates FitStatistics;
proc glmselect data=data.resilience3 plots=all seed=712;
title1 "SELECTION=ELASTICNET(L2SEARCH=GOLDEN L2LOW= &amp;amp;l2_cust_low L2HIGH= &amp;amp;l2_cust_high))";
title2 "Primary Analysis";
partition fraction(test=0.3);
class 	sex(ref='0') nonhisp_black(ref='0') nonhisp_white(ref='0') hispanic(ref='0') Married(ref='0') single(ref='0')
		ged_hsdiploma(ref='0') Assoc_Bachelor(ref='0') graduate(ref='0') Tetra_abc(ref='0') para_abc(ref='0')
		sleep(ref='0') pain_interfere2(ref='0') Healthsts_pos(ref='0') fyear_1(ref='0') fyear_5(ref='0') fyear_10(ref='0') 
		fyear_15(ref='0') fyear_20_25(ref='0') fyear_30plus(ref='0');
model BRsTScr2 = age sex nonhisp_black nonhisp_white hispanic Married single  
					ged_hsdiploma Assoc_Bachelor graduate Tetra_abc para_abc
					fyear_5 fyear_10 fyear_15 fyear_20_25 fyear_30plus
					BSFBMTS2 BSFSCTS2 BSFFMoTS2 sleep pain pain_interfere2 Healthsts_pos 
					BCHPITot2 BCHMbTot2 BCHOpTot2 BCHSocIn2 depression life_sat pain*depression / 
					SELECTION=ELASTICNET(L2SEARCH=GOLDEN L2LOW= &amp;amp;l2_cust_low L2HIGH= &amp;amp;l2_cust_high choose = cv) 
					cvmethod=split(10) hierarchy=none showpvalues;
					
run;
%MEND elasticnet;

%elasticnet(0,0.1);
%elasticnet(0.1,0.2);
%elasticnet(0.2,0.3);
%elasticnet(0.3,0.4);
%elasticnet(0.4,0.5);
%elasticnet(0.5,0.6);
%elasticnet(0.6,0.7);
%elasticnet(0.7,0.8);
%elasticnet(0.8,0.9);
%elasticnet(0.9,1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any and all help will be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 15:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Elastic-Net-selection-with-interaction-effects/m-p/707687#M217317</guid>
      <dc:creator>delgaa07</dc:creator>
      <dc:date>2020-12-22T15:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Elastic Net selection with interaction effects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Elastic-Net-selection-with-interaction-effects/m-p/707895#M217430</link>
      <description>&lt;P&gt;For some selection methods, you can use HIERARCHY=SINGLE or INCLUDE=&lt;EM&gt;n&lt;/EM&gt;&amp;nbsp;to force terms to stay in the model. However, the elastic net method does not support those options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the best you can do is to run the procedure twice. The first time, use the SELECTION=ELASTICNET method to choose effects for the model. Then run the procedure again using SELECTION=NONE to fit the model, but force the main effects that you want in the model. &lt;A href="https://blogs.sas.com/content/iml/2018/08/01/variables-in-final-selected-model.html" target="_self"&gt;The first run creates the&amp;nbsp;_GLSIND macro variable, which contains the selected effects&lt;/A&gt;.&amp;nbsp; Therefore, if the pain*depression effect is selected, the second model will be&lt;/P&gt;
&lt;P&gt;MODEL&amp;nbsp;BRsTScr2 = pain depression &amp;amp;_GLSIND / selection=none;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your example, in your&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 15:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Elastic-Net-selection-with-interaction-effects/m-p/707895#M217430</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-12-23T15:00:11Z</dc:date>
    </item>
  </channel>
</rss>

