<?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: newey-west correction for count data? in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744136#M4119</link>
    <description>You might post it at Forecasting Forum , since PROC MODEL is under SAS/ETS .</description>
    <pubDate>Thu, 27 May 2021 13:10:43 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-05-27T13:10:43Z</dc:date>
    <item>
      <title>newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/743921#M4116</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my first time posting a question, so I'm a bit nervous &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a clinician not a statistician, so please excuse any naivete. I am modelling an interrupted time series analysis with 2 breakpoints, using GLM and an impact model with 2 slope changes and 2 level changes, no other covariates included. The dependent variable is a count, Poisson distributed. I found autocorrelation at lag 3 only. I'm using SAS 9.4.&lt;/P&gt;&lt;P&gt;I read about using the Newey-West correction for autocorrelation in time series, however I wasn't sure if that was appropriate for a count distribution? All the SAS codes I've seen were applied to continuous DV, so I essentially adapted those codes to my count model - but i'm not sure this is right...more specifically I'm asking:&lt;/P&gt;&lt;P&gt;- is newey west correction appropriate for a count model?&lt;/P&gt;&lt;P&gt;- if it is, did I code it correctly? (I've essentially taken the newey-west correction i've seen used in a proc model but for a continuous DV and applied it to mine)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no errors that come up when i run this or anything else weird but the reason I'm asking is that my mentor is doing the same analysis using STATA and is getting VERY different standard errors. So we're trying to figure out if I made a mistake in my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much!&lt;/P&gt;&lt;P&gt;Gabriela&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Explanation of variables:&lt;/P&gt;&lt;P&gt;slopech1_2 = slope change from period 1 to 2&lt;/P&gt;&lt;P&gt;jump1_2 = level change from period 1 to 2 (same for periods 2 to 3)&lt;/P&gt;&lt;P&gt;time = month1 to 50 of 50 months (monthly measurements)&lt;/P&gt;&lt;P&gt;Exposure = exposure variable for each month&lt;/P&gt;&lt;P&gt;y= observed variable of interest (rate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;model&lt;/STRONG&gt; data=Trends;&lt;/P&gt;&lt;P&gt;label b0="intercept" b1="time" b2="slopech1_2" b3="jump1_2" b4="slopech2_3" b5="jump2_3";&lt;/P&gt;&lt;P&gt;parms b0 = &lt;STRONG&gt;0.5&lt;/STRONG&gt; b1 = &lt;STRONG&gt;0.1&lt;/STRONG&gt; b2=&lt;STRONG&gt;0.1&lt;/STRONG&gt; b3=&lt;STRONG&gt;0.1&lt;/STRONG&gt; b4=&lt;STRONG&gt;0.1&lt;/STRONG&gt; b5=&lt;STRONG&gt;0.1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;yhat=exp(b0+b1*time+b2*slopech1_2+b3*jump1_2+b4*slopech2_3+b5*jump2_3)*Exposure;&lt;/P&gt;&lt;P&gt;y=yhat;&lt;/P&gt;&lt;P&gt;lk=exp(-yhat)*(yhat**y)/fact(y);&lt;/P&gt;&lt;P&gt;ll=-log(lk);&lt;/P&gt;&lt;P&gt;errormodel clots~general(ll);&lt;/P&gt;&lt;P&gt;fit clots/gmm kernel=(bart,&lt;STRONG&gt;4&lt;/STRONG&gt;,&lt;STRONG&gt;0&lt;/STRONG&gt;) vardef=n;&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;Attached is a sample of the dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 15:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/743921#M4116</guid>
      <dc:creator>Gabi3</dc:creator>
      <dc:date>2021-05-26T15:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744129#M4117</link>
      <description>&lt;P&gt;I don't know if it is a mistake, but it seems unusual that these two lines are in there:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;lk=exp(-yhat)*(yhat**y)/fact(y);

ll=-log(lk);&lt;/PRE&gt;
&lt;P&gt;That would imply that the log likelihood is just&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;lk=(yhat)*(yhat**y)/fact(y);

&lt;/PRE&gt;
&lt;P&gt;and that doesn't seem right somehow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 12:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744129#M4117</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-05-27T12:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744133#M4118</link>
      <description>&lt;P&gt;Although Steve's computations are a bit off&lt;/P&gt;
&lt;P&gt;(I believe the correct computation is ll = -yhat + y*log(yhat) - LFACT(y)?)&lt;/P&gt;
&lt;P&gt;his main point is valid: check the log-likelihood function.&amp;nbsp; Furthermore, for numerical stability, it is best to avoid forming the full likelihood and then taking the log. Instead, compute the log-likelihood directly, as shown in this article:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/06/12/log-likelihood-function-in-sas.html" target="_self"&gt;Two simple ways to construct a log-likelihood function in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some tips on specifying lo-likelihoods are available at&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/06/14/maximum-likelihood-estimates-in-sas.html" target="_self"&gt;Two ways to compute maximum likelihood estimates in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This article talks about PROC NLMIXED, but the tips apply to other SAS procedures, too.&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 12:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744133#M4118</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-05-28T12:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744136#M4119</link>
      <description>You might post it at Forecasting Forum , since PROC MODEL is under SAS/ETS .</description>
      <pubDate>Thu, 27 May 2021 13:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744136#M4119</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-27T13:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744366#M4120</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;.&amp;nbsp; I missed that there was no closing parenthesis, so that the exp(yhat) is the only term that transforms back to the original scale in this representation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, this code calculates the log-likelihood as -yhat+y*log(yhat)-LFACT(y), and thus is off by a factor of y/2 after removing the identical parts of the calculation (check me here, Rick).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 11:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744366#M4120</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-05-28T11:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744373#M4121</link>
      <description>&lt;P&gt;I don't know the correct LL, but the OP's program has the line&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;y=yhat;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which seems very strange. The OP's comments indicate that y should be an observed variable (the count).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 12:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744373#M4121</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-05-28T12:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744436#M4122</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thanks guys!! I'm sorry to ask this, but I am a clinician so not really&lt;BR /&gt;mathematically savvy. Could you re-write the code with the proper syntax&lt;BR /&gt;for me? It would take me quite a bit of time to figure it out and would be&lt;BR /&gt;of great help (since i'm sure its super easy for you).&lt;BR /&gt;&lt;BR /&gt;Also, any thoughts on the newey correction? Both in regards to the&lt;BR /&gt;applicability to the count model AND the syntax?&lt;BR /&gt;&lt;BR /&gt;Thanks very much, appreciate it,&lt;BR /&gt;&lt;BR /&gt;Gabi&lt;BR /&gt;</description>
      <pubDate>Fri, 28 May 2021 15:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744436#M4122</guid>
      <dc:creator>Gabi3</dc:creator>
      <dc:date>2021-05-28T15:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744675#M4123</link>
      <description>Thanks, good idea.&lt;BR /&gt;Is there a quick way of doing this, or should I copy / paste the entire thing into a different forum?&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;Gabi</description>
      <pubDate>Sun, 30 May 2021 15:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744675#M4123</guid>
      <dc:creator>Gabi3</dc:creator>
      <dc:date>2021-05-30T15:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: newey-west correction for count data?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744765#M4126</link>
      <description>Yeah. Post your question at this forum. Some expert about SAS/ETS might give you a hand.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/bd-p/forecasting_econometrics" target="_blank"&gt;https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/bd-p/forecasting_econometrics&lt;/A&gt;</description>
      <pubDate>Mon, 31 May 2021 11:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/newey-west-correction-for-count-data/m-p/744765#M4126</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-31T11:54:57Z</dc:date>
    </item>
  </channel>
</rss>

