<?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: likelihood ratio test for proc GLM with all category variables in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920203#M45715</link>
    <description>&lt;P&gt;First, that is way too little data for the size of the model. There are insufficient degrees of freedom to estimate all of the parameters. Regarding getting a likelihood ratio test, you should use a procedure that uses maximum likelihood estimation. GLM uses least squares, not maximum likelihood. If you have a much simpler model, or if you have many more data points, then you can get a likelihood ratio test easily in PROC GENMOD, which uses maximum likelihood estimation,&amp;nbsp; by just including the TYPE3 option. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=sample_data;
  class gender  group;
  model cost =gender  group / type3;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Mar 2024 21:39:18 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2024-03-13T21:39:18Z</dc:date>
    <item>
      <title>likelihood ratio test for proc GLM with all category variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920202#M45714</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I want to test if&amp;nbsp; the full linear regression model with group factor&amp;nbsp; significantly better than&amp;nbsp; the reduced model, but I can't get the&amp;nbsp;statistic as below, &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Creating sample data */&lt;/P&gt;&lt;P&gt;data sample_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input cost agegroup $ gender $ regions $ race $ group ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;100 20-30 Male East Asian 1&lt;/P&gt;&lt;P&gt;150 30-40 Female West Black 0&lt;/P&gt;&lt;P&gt;200 40-50 Male South White 1&lt;/P&gt;&lt;P&gt;250 20-30 Female East Hispanic 1&lt;/P&gt;&lt;P&gt;300 30-40 Male West White 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* Fit reduce&amp;nbsp; model without group indicator */&lt;/P&gt;&lt;P&gt;proc glm data=sample_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class agegroup gender regions race;&lt;/P&gt;&lt;P&gt;&amp;nbsp; model cost = agegroup gender regions race / solution;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output ParameterEstimates=Model1_out;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Fit the full model with&amp;nbsp; group&amp;nbsp; */&lt;/P&gt;&lt;P&gt;proc glm data=sample_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class agegroup gender regions race group;&lt;/P&gt;&lt;P&gt;&amp;nbsp; model cost =agegroup gender regions race group / solution;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output ParameterEstimates=Model2_out;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* Calculate the log-likelihood for each model */&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data lst;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; set Model1_out;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; loglik1 = -0.5 * (_N_ * log(2 * constant('pi')) + _SSE_);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Model2_out;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Model2_out;&lt;/P&gt;&lt;P&gt;&amp;nbsp; loglik2 = -0.5 * (_N_ * log(2 * constant('pi')) + _SSE_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Calculate the likelihood ratio test statistic */&lt;/P&gt;&lt;P&gt;data lst;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Model1_out;&lt;/P&gt;&lt;P&gt;&amp;nbsp; loglik2 = loglik2;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LR = -2 * (loglik1 - loglik2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; p_value = 1 - cdf('CHISQUARE', LR, 1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 21:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920202#M45714</guid>
      <dc:creator>xinyao</dc:creator>
      <dc:date>2024-03-13T21:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: likelihood ratio test for proc GLM with all category variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920203#M45715</link>
      <description>&lt;P&gt;First, that is way too little data for the size of the model. There are insufficient degrees of freedom to estimate all of the parameters. Regarding getting a likelihood ratio test, you should use a procedure that uses maximum likelihood estimation. GLM uses least squares, not maximum likelihood. If you have a much simpler model, or if you have many more data points, then you can get a likelihood ratio test easily in PROC GENMOD, which uses maximum likelihood estimation,&amp;nbsp; by just including the TYPE3 option. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=sample_data;
  class gender  group;
  model cost =gender  group / type3;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2024 21:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920203#M45715</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2024-03-13T21:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: likelihood ratio test for proc GLM with all category variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920209#M45716</link>
      <description>&lt;P&gt;Thank you! sorry for small example data,&lt;/P&gt;&lt;P&gt;i need include all demographic variable in the model,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can I use below model to do two model comparison?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc genmod data=data ;&lt;BR /&gt;class Agegrp gender race region group;&lt;BR /&gt;model&amp;nbsp; cost = Agegrp gender race region group / dist=normal link=identity type3;&lt;BR /&gt;output out=model2_out stdresdev=stdresdev p=predicted;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc genmod data=model2_out;&lt;BR /&gt;class Agegrp gender race region group;&lt;BR /&gt;model cost = Agegrp gender race region group / dist=normal link=identity type3;&lt;BR /&gt;contrast 'Wald Test for Model Comparison' Agegrp gender race region 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 / e Wald;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 22:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920209#M45716</guid>
      <dc:creator>xinyao</dc:creator>
      <dc:date>2024-03-13T22:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: likelihood ratio test for proc GLM with all category variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920212#M45717</link>
      <description>The point is that you don't need to run PROC GENMOD twice. The TYPE3 test for GROUP is the likelihood ratio test you want. So, you just need the results from your first PROC GENMOD step.</description>
      <pubDate>Wed, 13 Mar 2024 22:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/likelihood-ratio-test-for-proc-GLM-with-all-category-variables/m-p/920212#M45717</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2024-03-13T22:43:55Z</dc:date>
    </item>
  </channel>
</rss>

