<?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 ARIMA Models in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954721#M4912</link>
    <description>&lt;P&gt;Your code looks good. Maybe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; could answer your question.&lt;/P&gt;</description>
    <pubDate>Sun, 29 Dec 2024 06:14:41 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-12-29T06:14:41Z</dc:date>
    <item>
      <title>Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954712#M4909</link>
      <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;
&lt;P&gt;I would appreciate your assistance with a question regarding the discrimination between two ARIMA models using a likelihood ratio test.&lt;/P&gt;
&lt;P&gt;Suppose, the full model is as follows:&lt;/P&gt;
&lt;PRE&gt;proc arima data=a;
   identify var=zt;
   estimate p=3 q=0 method=ml;
run;&lt;/PRE&gt;
&lt;P&gt;The restricted model is:&lt;/P&gt;
&lt;PRE&gt;proc arima data=a; &lt;BR /&gt;identify var=zt; &lt;BR /&gt;estimate p=(1 3) q=0 method=ml; &lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;I understand that one approach is to manually compute the test statistic using the formula:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="katex-display"&gt;&lt;SPAN class="katex"&gt;&lt;SPAN class="katex-mathml"&gt;LR=2*(LL_Full−LL_Restricted)&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;and then compare it with the chi-squared distribution with the appropriate degrees of freedom.&lt;/P&gt;
&lt;P&gt;However, I was wondering if there is a more efficient or automated way to perform this test within SAS (for any arbitrary full vs restricted ARIMA models), rather than calculating it manually.&lt;/P&gt;
&lt;P&gt;Any guidance or suggestions would be greatly appreciated!&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Dec 2024 15:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954712#M4909</guid>
      <dc:creator>sasalex2024</dc:creator>
      <dc:date>2024-12-28T15:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954719#M4910</link>
      <description>You could save these Likelihood and perform this test by code(or SAS/IML).&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; blog could give you a hand:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/03/27/likelihood-ratio-test.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2024/03/27/likelihood-ratio-test.html&lt;/A&gt;</description>
      <pubDate>Sun, 29 Dec 2024 01:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954719#M4910</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-29T01:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954720#M4911</link>
      <description>&lt;P&gt;Dear Ksharp,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for the prompt and insightful reply. I've used the modified version of the code you referred to, and though my version perhaps is not the most efficient one, it seems to work. Do you think it can be accepted as a solution? Here is the code below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* ARIMA Model 1 (with more parameters) */
proc arima data=a plots=none;
identify var=zt;
estimate p=3 q=0 method=ml outstat=LLFull;
run;

/* ARIMA Model 2 (with fewer parameters) */
proc arima data=a plots=none;
identify var=zt;
estimate p=(1  3) q=0 method=ml outstat=LLRed;
run;&lt;/PRE&gt;
&lt;PRE&gt;/* NOTE: If 'Pr &amp;gt; ChiSq' value exceeds 0.05, the model with more parameters is preferred */&lt;BR /&gt;data LRTEST;    &lt;BR /&gt;    retain LR_Test; &lt;BR /&gt;    merge LLFULL(keep=_VALUE_ rename=(_VALUE_=valueFull))&lt;BR /&gt;          LLRED(keep=_VALUE_ rename=(_VALUE_=valueRed));&lt;BR /&gt;    &lt;BR /&gt;    if _N_ = 3 then&lt;BR /&gt;        LR_Test = 2 * abs(valueFull - valueRed);&lt;BR /&gt;    if _N_ = 6 then do&lt;BR /&gt;        DF = valueFull - valueRed;&lt;BR /&gt;        pValue = sdf("ChiSq", LR_Test, DF); &lt;BR /&gt;    end;&lt;BR /&gt;    &lt;BR /&gt;    label LR_Test='LR_Stat' pValue = 'Pr &amp;gt; ChiSq';&lt;BR /&gt;    drop valueFull valueRed DF;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print data=LRTEST (firstobs=6 obs=6) label noobs;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 Dec 2024 05:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954720#M4911</guid>
      <dc:creator>sasalex2024</dc:creator>
      <dc:date>2024-12-29T05:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954721#M4912</link>
      <description>&lt;P&gt;Your code looks good. Maybe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; could answer your question.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2024 06:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954721#M4912</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-29T06:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954723#M4913</link>
      <description>&lt;P&gt;Your code looks correct. I suggest a few minor changes for readability and efficiency:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You don't need to call PROC ARIMA twice. Call it once and use two ESTIMATE statements.&lt;/LI&gt;
&lt;LI&gt;Use readable code such as IF _STAT_ = "LOGLIK" instead of using IF _N_ = 3.&lt;/LI&gt;
&lt;LI&gt;Include an OUTPUT statement so the final data set has one row.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
call streaminit(123);
do i = 1 to 100;
   zt = rand("Normal");
   output;
end;
run;


/* ARIMA Models */
proc arima data=a plots=none;
identify var=zt;
Full: estimate p=3 q=0 method=ml outstat=LLFull;
Reduced: estimate p=(1  3) q=0 method=ml outstat=LLRed;
run;
quit;

/* NOTE: If 'Pr &amp;gt; ChiSq' value exceeds 0.05, the model with more parameters is preferred */
data LRTEST;    
   label valueFull="LL(Full)" valueRed="LL(Reduced)" DF="DF" 
         LR_Test='LR_Stat' pValue = 'Pr &amp;gt; ChiSq';
   format pValue PVALUE6.4;

   retain LR_Test DF pValue; 
   merge LLFULL(keep=_STAT_ _VALUE_ rename=(_VALUE_=valueFull))
       LLRED(keep=_STAT_ _VALUE_ rename=(_VALUE_=valueRed));

   if _STAT_ = "LOGLIK" then
     LR_Test = 2 * abs(valueFull - valueRed);
   else if _STAT_ = "NPARMS" then do
     DF = valueFull - valueRed;
     pValue = sdf("ChiSq", LR_Test, DF); 
     output;
   end;
   drop _STAT_;
run;

proc print data=LRTEST label noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2024 11:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954723#M4913</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-12-29T11:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954725#M4914</link>
      <description>&lt;P&gt;Thank you very much Rick_SAS, this is way better than mine. The only thing is, the printed table at the end doesn't display LL values (&lt;SPAN&gt;LOGLIK&lt;/SPAN&gt;) in the 1st two columns, but apparently the number of paramaters in those model.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2024 14:16:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954725#M4914</guid>
      <dc:creator>sasalex2024</dc:creator>
      <dc:date>2024-12-29T14:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Likelihood Ratio Test for ARIMA Models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954753#M4915</link>
      <description>&lt;P&gt;Apologies. Try this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* LR test: If 'Pr &amp;gt; ChiSq' value exceeds 0.05, the model with more parameters is preferred */
data LRTEST;    
   label LLFull="LL(Full)" LLRed="LL(Reduced)" DF="DF" 
         LR_Test='LR_Stat' pValue = 'Pr &amp;gt; ChiSq';
   format pValue PVALUE6.4;

   retain LLFull LLRed LR_Test DF pValue; 
   merge LLFULL(keep=_STAT_ _VALUE_ rename=(_VALUE_=valueFull))
       LLRED(keep=_STAT_ _VALUE_ rename=(_VALUE_=valueRed));

   if _STAT_ = "LOGLIK" then do;
     LLFull = valueFull;
     LLRed = valueRed; 
     LR_Test = 2 * abs(LLFull - LLRed);
   end;
   else if _STAT_ = "NPARMS" then do
     DF = valueFull - valueRed;
     pValue = sdf("ChiSq", LR_Test, DF); 
     output;
   end;
   drop _STAT_ valueFull valueRed;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Dec 2024 10:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Likelihood-Ratio-Test-for-ARIMA-Models/m-p/954753#M4915</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-12-30T10:58:40Z</dc:date>
    </item>
  </channel>
</rss>

