<?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 Re: Guidance on PROC LOGISTIC for Interaction Terms and Contrast Statements in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Guidance-on-PROC-LOGISTIC-for-Interaction-Terms-and-Contrast/m-p/926183#M46058</link>
    <description>&lt;DIV&gt;&lt;SPAN&gt;Here's code for an example dataset.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc logistic data = sashelp.heart;
	class Status Smoking_Status(ref = 'Non-smoker') Sex(ref = 'Male') / param = glm;
	model Status(event = 'Dead') = Smoking_Status | Sex Cholesterol Weight / expb;
	estimate 'Female; Heavy (16-25)' intercept 1 Smoking_Status 1 Sex 1 Smoking_Status*Sex 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Heavy (16-25)' intercept 1 Smoking_Status 1 Sex 0 1 Smoking_Status*Sex 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Light (1-5)' intercept 1 Smoking_Status 0 1 Sex 1 Smoking_Status*Sex 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Light (1-5)' intercept 1 Smoking_Status 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Moderate (6-15)' intercept 1 Smoking_Status 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Moderate (6-15)' intercept 1 Smoking_Status 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Very Heavy (&amp;gt; 25)' intercept 1 Smoking_Status 0 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Very Heavy (&amp;gt; 25)' intercept 1 Smoking_Status 0 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Non-smoker' intercept 1 Smoking_Status 0 0 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Non-smoker' intercept 1 Smoking_Status 0 0 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	lsmeans Smoking_Status * Sex / at means ilink pdiff oddsratio cl;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;To write contrasts/estimates, I like to use the "e" option and print out the&amp;nbsp;least squares means to make sure I'm writing them correctly.&amp;nbsp; Categorical&amp;nbsp;variables will have all levels used with GLM parameterization.&amp;nbsp; In simpler&amp;nbsp;cases, 1s are used for the levels of interest and 0s otherwise for&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;estimates.&amp;nbsp; For continuous variables, we can make predictions at the mean&amp;nbsp;values of these variables.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc means data = sashelp.heart;
	var Cholesterol Weight;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;This is done with the "at means" option in the lsmeans statement.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I don't think that your current code includes any odd ratios.&amp;nbsp; You can get odds ratios from the logistic regression coefficients with the "expb" option in the model statement.&amp;nbsp; The above estimate statements give you log-odds estimates and predicted probabilities (ilink option).&amp;nbsp; See the calculations below for 'Female; Heavy (16-25)'.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
	logOdds = -0.7022;
	odds = exp(logOdds);
	prob = exp(logOdds) / (exp(logOdds) + 1);
	put logOdds = odds = prob = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;Exponentiating the log-odds estimates will give you the odds estimates.&amp;nbsp; Adding the "pdiff" and "oddsratio" options to the lsmeans statement will give&amp;nbsp;differences in log-odds and odds ratios.&amp;nbsp; See the calculations below for 'Female; Heavy (16-25)' vs 'Male; Heavy (16-25)'.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
	logOddsDiff = -0.7022 - (-0.1660);
	oddsRatio = exp(logOddsDiff);
	put logOddsDiff = oddsRatio = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;This modified code gives the difference in log-odds and odds ratio for 'Female; Heavy (16-25) vs Male; Heavy (16-25)' which is just subtracting&amp;nbsp;the individual estimates.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc logistic data = sashelp.heart;
	class Status Smoking_Status(ref = 'Non-smoker') Sex(ref = 'Male') / param = glm;
	model Status(event = 'Dead') = Smoking_Status | Sex Cholesterol Weight / expb;
	estimate 'Female; Heavy (16-25) vs Male; Heavy (16-25)' Sex 1 -1 Smoking_Status*Sex 1 -1 / exp ilink e cl;
	lsmeans Smoking_Status * Sex / at means ilink pdiff oddsratio cl;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;Hopefully this helps you to apply it to your own dataset.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For #2, I would report the odds ratios corresponding to the interaction&amp;nbsp;since it seems to be what you are interested in.&amp;nbsp; For #3, look up&amp;nbsp;quasi-complete separation.&amp;nbsp; For #4, include the interactions justified by&amp;nbsp;the theory and literature.&lt;/DIV&gt;</description>
    <pubDate>Sat, 27 Apr 2024 21:16:04 GMT</pubDate>
    <dc:creator>dpalmer1</dc:creator>
    <dc:date>2024-04-27T21:16:04Z</dc:date>
    <item>
      <title>Guidance on PROC LOGISTIC for Interaction Terms and Contrast Statements</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Guidance-on-PROC-LOGISTIC-for-Interaction-Terms-and-Contrast/m-p/923347#M45886</link>
      <description>&lt;P&gt;Hello SAS Community,&lt;/P&gt;&lt;P&gt;I have a class project that analyzes factors associated with a binary outcome within a CBT intervention program. The dataset includes a categorical exposure variable (&lt;CODE&gt;cbtmod&lt;/CODE&gt;) with three levels (1,2,3), along with other predictors.&lt;/P&gt;&lt;P&gt;The study aims to answer two main research questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;What risk factors are associated with the binary outcome among participants, and how do these vary across different CBT modalities, especially with respect to sex differences?&lt;/LI&gt;&lt;LI&gt;How do perceptions regarding the safety of the CBT intervention differ by modality, what factors contribute to these differences, and how do these vary by sex?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Mainly, I'm interested in the interactions between &lt;CODE&gt;cbtmod&lt;/CODE&gt; and &lt;CODE&gt;sex&lt;/CODE&gt; (coded as 0 for males and 1 for females), as well as &lt;CODE&gt;cbtmod&lt;/CODE&gt;'s interactions with all other variables in the model, as advised by my supervisor.&lt;/P&gt;&lt;P&gt;I've structured the &lt;CODE&gt;PROC LOGISTIC&lt;/CODE&gt; for the fully adjusted model to check for interaction as follows:&lt;/P&gt;&lt;PRE&gt;proc logistic data=mydata;
    class cbtmod(ref='1') sex(ref='0') / param=ref;
    model outcome(event='1') = cbtmod sex hh_disabilityn pregnant_1_sex Marriage Resstatus cbtmod*sex / lackfit clodds=wald;
    contrast 'cbtmod=2 for males' cbtmod 2 cbtmod*sex 0 / est=exp;
    contrast 'cbtmod=2 for females' cbtmod 2 cbtmod*sex 1 / est=exp;
    contrast 'cbtmod=3 for males' cbtmod 3 cbtmod*sex 0 /est=exp;
 contrast 'cbtmod=3 for females' cbtmod 3 cbtmod*sex 1 / est=exp;
run;&lt;/PRE&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Interaction Testing&lt;/STRONG&gt;: Is this setup correct for testing the interaction between &lt;CODE&gt;cbtmod&lt;/CODE&gt; and &lt;CODE&gt;sex&lt;/CODE&gt;? How should I structure my &lt;CODE&gt;CONTRAST&lt;/CODE&gt; statements to best explore these interaction effects across different CBT modalities by sex?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Fully Adjusted Model Reporting&lt;/STRONG&gt;: In the context of the fully adjusted model that includes interaction terms, what are the essential values or estimates to report for a comprehensive interpretation? Should&amp;nbsp; I report the aOR for the interaction term or just the exposure and should the interaction term be included if I am reporting the aor for the full model?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Handling Zero Cell Counts&lt;/STRONG&gt;: For my second research question, I encounter a scenario where, for males (&lt;CODE&gt;sex=0&lt;/CODE&gt;), with the outcome being 0 and &lt;CODE&gt;cbtmod=3&lt;/CODE&gt;, there is a cell count of 0. How should this be addressed in the logistic regression analysis? Should I just make a note of it in the limitation section of my report?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Checking Interactions with Other Variables&lt;/STRONG&gt;: Given the directive to check for interactions between &lt;CODE&gt;cbtmod&lt;/CODE&gt; and all other variables, what would be an efficient strategy to approach this without complicating the model unnecessarily?&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I value any insights or guidance on refining my approach, particularly regarding &lt;CODE&gt;CONTRAST&lt;/CODE&gt; statements for interaction testing, strategies for addressing zero cell counts, and managing multiple interactions in logistic regression.&lt;/P&gt;&lt;P&gt;Thank you for your assistance!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 18:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Guidance-on-PROC-LOGISTIC-for-Interaction-Terms-and-Contrast/m-p/923347#M45886</guid>
      <dc:creator>Iamhumerus77</dc:creator>
      <dc:date>2024-04-07T18:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Guidance on PROC LOGISTIC for Interaction Terms and Contrast Statements</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Guidance-on-PROC-LOGISTIC-for-Interaction-Terms-and-Contrast/m-p/926183#M46058</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;Here's code for an example dataset.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc logistic data = sashelp.heart;
	class Status Smoking_Status(ref = 'Non-smoker') Sex(ref = 'Male') / param = glm;
	model Status(event = 'Dead') = Smoking_Status | Sex Cholesterol Weight / expb;
	estimate 'Female; Heavy (16-25)' intercept 1 Smoking_Status 1 Sex 1 Smoking_Status*Sex 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Heavy (16-25)' intercept 1 Smoking_Status 1 Sex 0 1 Smoking_Status*Sex 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Light (1-5)' intercept 1 Smoking_Status 0 1 Sex 1 Smoking_Status*Sex 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Light (1-5)' intercept 1 Smoking_Status 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Moderate (6-15)' intercept 1 Smoking_Status 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Moderate (6-15)' intercept 1 Smoking_Status 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Very Heavy (&amp;gt; 25)' intercept 1 Smoking_Status 0 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Very Heavy (&amp;gt; 25)' intercept 1 Smoking_Status 0 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Female; Non-smoker' intercept 1 Smoking_Status 0 0 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	estimate 'Male; Non-smoker' intercept 1 Smoking_Status 0 0 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
	lsmeans Smoking_Status * Sex / at means ilink pdiff oddsratio cl;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;To write contrasts/estimates, I like to use the "e" option and print out the&amp;nbsp;least squares means to make sure I'm writing them correctly.&amp;nbsp; Categorical&amp;nbsp;variables will have all levels used with GLM parameterization.&amp;nbsp; In simpler&amp;nbsp;cases, 1s are used for the levels of interest and 0s otherwise for&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;estimates.&amp;nbsp; For continuous variables, we can make predictions at the mean&amp;nbsp;values of these variables.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc means data = sashelp.heart;
	var Cholesterol Weight;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;This is done with the "at means" option in the lsmeans statement.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I don't think that your current code includes any odd ratios.&amp;nbsp; You can get odds ratios from the logistic regression coefficients with the "expb" option in the model statement.&amp;nbsp; The above estimate statements give you log-odds estimates and predicted probabilities (ilink option).&amp;nbsp; See the calculations below for 'Female; Heavy (16-25)'.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
	logOdds = -0.7022;
	odds = exp(logOdds);
	prob = exp(logOdds) / (exp(logOdds) + 1);
	put logOdds = odds = prob = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;Exponentiating the log-odds estimates will give you the odds estimates.&amp;nbsp; Adding the "pdiff" and "oddsratio" options to the lsmeans statement will give&amp;nbsp;differences in log-odds and odds ratios.&amp;nbsp; See the calculations below for 'Female; Heavy (16-25)' vs 'Male; Heavy (16-25)'.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
	logOddsDiff = -0.7022 - (-0.1660);
	oddsRatio = exp(logOddsDiff);
	put logOddsDiff = oddsRatio = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;This modified code gives the difference in log-odds and odds ratio for 'Female; Heavy (16-25) vs Male; Heavy (16-25)' which is just subtracting&amp;nbsp;the individual estimates.&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc logistic data = sashelp.heart;
	class Status Smoking_Status(ref = 'Non-smoker') Sex(ref = 'Male') / param = glm;
	model Status(event = 'Dead') = Smoking_Status | Sex Cholesterol Weight / expb;
	estimate 'Female; Heavy (16-25) vs Male; Heavy (16-25)' Sex 1 -1 Smoking_Status*Sex 1 -1 / exp ilink e cl;
	lsmeans Smoking_Status * Sex / at means ilink pdiff oddsratio cl;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;Hopefully this helps you to apply it to your own dataset.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For #2, I would report the odds ratios corresponding to the interaction&amp;nbsp;since it seems to be what you are interested in.&amp;nbsp; For #3, look up&amp;nbsp;quasi-complete separation.&amp;nbsp; For #4, include the interactions justified by&amp;nbsp;the theory and literature.&lt;/DIV&gt;</description>
      <pubDate>Sat, 27 Apr 2024 21:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Guidance-on-PROC-LOGISTIC-for-Interaction-Terms-and-Contrast/m-p/926183#M46058</guid>
      <dc:creator>dpalmer1</dc:creator>
      <dc:date>2024-04-27T21:16:04Z</dc:date>
    </item>
  </channel>
</rss>

