<?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: LR test in proc genmod in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/764428#M37330</link>
    <description>&lt;P&gt;I'm not seeing any contradiction.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Aug 2021 11:25:19 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-08-27T11:25:19Z</dc:date>
    <item>
      <title>LR test in proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/762881#M37237</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I'm using proc genmod for building GLM models. In variable selection we generally use LR test with type 3 statistics.&lt;/P&gt;&lt;P&gt;As I understand the LR test is working the following way:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dofin_0-1629473707796.png" style="width: 559px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62780iB07EB366DD0A43D6/image-dimensions/559x24?v=v2" width="559" height="24" role="button" title="Dofin_0-1629473707796.png" alt="Dofin_0-1629473707796.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;D-deviance&lt;/P&gt;&lt;P&gt;which is distributed Chi-Square when number of degrees of freedom is equal to number of levels in investigated variable minus 1. That's true until a model&amp;nbsp; includes interaction.&lt;/P&gt;&lt;P&gt;Suppose a model consists of 2 variables and their interaction: A,B,A*B&lt;/P&gt;&lt;P&gt;So, the LR test for variable A is supposed to be:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dofin_1-1629474021572.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62781iE311043E2ECB45CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dofin_1-1629474021572.png" alt="Dofin_1-1629474021572.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;but I found occasionally that deviance is equal for 2 models: B,A*B and A,B,A*B&lt;/P&gt;&lt;P&gt;so this formula cannot be applied in this case&lt;/P&gt;&lt;P&gt;If anybody knows how SAS computes LR statistics for model with interaction?&lt;/P&gt;&lt;P&gt;This very important to me and I will be very appreciate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;Alex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 16:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/762881#M37237</guid>
      <dc:creator>Dofin</dc:creator>
      <dc:date>2021-08-20T16:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: LR test in proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/762888#M37238</link>
      <description>&lt;P&gt;This has nothing to do with DEVIANCE or LR tests or PROC GENMOD. This is the way SAS handles non-hierarchical models, in all SAS PROCs as far as I know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first model with B and A*B is non-hierarchical in the sense that the main effect of A is not included, but A is included in a interaction. In this model with no main effect of A, the interaction has extra degrees of freedom, which includes the degrees of freedom for the main effect of A and the main effect of A is included in the parameter estimates of A*B along with the effect of A*B included. The model with A, B and A*B has the degrees of freedom for the main effect of A removed from A*B and included in the main effect of A, and also in this model the main effect of A is separated from the effect of A*B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the way SAS works, these are the same models, with the exact same fit and the exact same predictions; and the LR test should be zero. You have just requested the same model twice, but with different paramaterization.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title "Model 1";
proc genmod data=sashelp.cars;
class origin drivetrain;
model msrp=origin origin*drivetrain;
output out=model1_out pred=p;
run;
title "Model 2";
proc genmod data=sashelp.cars;
class origin drivetrain;
model msrp=origin drivetrain origin*drivetrain;
output out=model2_out pred=p;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the Deviance for each model is identical, and the predictions are identical for every observation. As it should be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above applies to cases where both A and B are CLASS, or just B is CLASS.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 18:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/762888#M37238</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-20T18:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: LR test in proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/763124#M37252</link>
      <description>&lt;P&gt;Thank you very much, very good explanation. I had feeling those are the same models.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem is that, when I have main factors and their interaction in the model LR Chi-Square statistics for main factors don't equal to zero (but should be). It looks like SAS makes some adjustment or additional computation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please take a look on the output of:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod=sashelp.cars;
class origin driventrain;
model msrp=origin driventrain origin*driventrain /link=log dist=gamma type3 scale=pearson;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;TABLE&gt;&lt;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&gt;DriveTrain&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;419&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;47.28&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;lt;.0001&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;94.57&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;lt;.0001&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Origin*DriveTrain&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;419&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2.11&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;0.0791&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;8.43&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;0.0771&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering how sas computes Ch-Square for Origin which is equal to 109.56, for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Sun, 22 Aug 2021 07:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/763124#M37252</guid>
      <dc:creator>Dofin</dc:creator>
      <dc:date>2021-08-22T07:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: LR test in proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/763142#M37253</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;But the problem is that, when I have main factors and their interaction in the model LR Chi-Square statistics for main factors don't equal to zero (but should be).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Should not be zero. And is not zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you think these should be zero, when there is an effect due to ORIGIN and an effect to DRIVETRAIN?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you have a question about how something is calculated, you should always check the SAS &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_genmod_toc.htm%20" target="_self"&gt;documentation for PROC GENMOD&lt;/A&gt; and then look under Details&lt;/P&gt;</description>
      <pubDate>Sun, 22 Aug 2021 11:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/763142#M37253</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-22T11:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: LR test in proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/764416#M37329</link>
      <description>&lt;P&gt;You've written LR test should be zero, see your previous post.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"So the way SAS works, these are the same models, with the exact same fit and the exact same predictions; and the LR test should be zero. You have just requested the same model twice, but with different paramaterization."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now you contradict to yourself.&lt;/P&gt;&lt;P&gt;The problem is the SAS documentation is very poor that why people ask here their questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 08:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/764416#M37329</guid>
      <dc:creator>Dofin</dc:creator>
      <dc:date>2021-08-27T08:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: LR test in proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/764428#M37330</link>
      <description>&lt;P&gt;I'm not seeing any contradiction.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 11:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/LR-test-in-proc-genmod/m-p/764428#M37330</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-27T11:25:19Z</dc:date>
    </item>
  </channel>
</rss>

