<?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: How do I change my code to find that my model satisfies the assumption that E(U|X) = 0? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533308#M73823</link>
    <description>Your code has no comments. When you're coding commenting really does help you ensure your code is correct and it's a good habit to get into.</description>
    <pubDate>Wed, 06 Feb 2019 15:49:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-02-06T15:49:19Z</dc:date>
    <item>
      <title>How do I change my code to find that my model satisfies the assumption that E(U|X) = 0?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533100#M73812</link>
      <description>&lt;P&gt;So I'm doing a simulation exercise where I had to make the error time be correlated with the independent variable X and see what happens to the empirical distribution. So I changed my code from this :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; samples;&lt;/P&gt;&lt;P&gt;do samp = &lt;STRONG&gt;1&lt;/STRONG&gt; to &lt;STRONG&gt;1000&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;do t = &lt;STRONG&gt;1&lt;/STRONG&gt; to &lt;STRONG&gt;100&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; u = rannor(&lt;STRONG&gt;1996&lt;/STRONG&gt;)*&lt;STRONG&gt;5&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = &lt;STRONG&gt;100&lt;/STRONG&gt; + &lt;STRONG&gt;3&lt;/STRONG&gt;*rannor(&lt;STRONG&gt;6991&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = &lt;STRONG&gt;10&lt;/STRONG&gt; + &lt;STRONG&gt;0.5&lt;/STRONG&gt;*x + u;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&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;to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; samples;&lt;/P&gt;&lt;P&gt;do samp = &lt;STRONG&gt;1&lt;/STRONG&gt; to &lt;STRONG&gt;1000&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;do t = &lt;STRONG&gt;1&lt;/STRONG&gt; to &lt;STRONG&gt;100&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; u = rannor(&lt;STRONG&gt;1996&lt;/STRONG&gt;)*&lt;STRONG&gt;5&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = &lt;STRONG&gt;100&lt;/STRONG&gt; + &lt;STRONG&gt;3&lt;/STRONG&gt;*rannor(&lt;STRONG&gt;6991&lt;/STRONG&gt;) + 0.3*u;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = &lt;STRONG&gt;10&lt;/STRONG&gt; + &lt;STRONG&gt;0.5&lt;/STRONG&gt;*x + u;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&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;Then I'm supposed to figure out of the model satisfies the assumption that E(U|X) = 0. To do this I have to run a single regression using only the first sample by putting WHERE SAMP=1 after the proc reg statement. Then I have to pull out the residuals and the predicted values of Y. Then I need t do a proc contents on the staset and have X,Y, Yhat, u and uhat in it. Then I need to calculate the correlation between X and uhat. I'm so confused how to go about this. Here is all my code if you guys can please help, thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data samples;&lt;BR /&gt;do samp = 1 to 1000;&lt;BR /&gt;do t = 1 to 100;&lt;BR /&gt;u = rannor(1996)*5;&lt;BR /&gt;x = 100 + 3*rannor(6991) + 0.3*u;&lt;BR /&gt;y = 10 + 0.5*x + u;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc corr;&lt;BR /&gt;where samp=1;&lt;BR /&gt;var x y u;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc reg data=samples outest=bvalues outseb noprint;&lt;BR /&gt;by samp;&lt;BR /&gt;model y = x;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data one two;&lt;BR /&gt;set bvalues;&lt;BR /&gt;if _type_ ='PARMS' then output one;&lt;BR /&gt;else if _type_ ='SEB' then output two;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table mystuff&lt;BR /&gt;as select one.intercept as b0hat, one.x as b1hat,&lt;BR /&gt;two.intercept as seb0, two.x as seb1&lt;BR /&gt;from one, two&lt;BR /&gt;where one.samp = two.samp;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc means data=mystuff;&lt;BR /&gt;var b0hat b1hat;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc univariate data=mystuff noprint;&lt;BR /&gt;var b0hat b1hat;&lt;BR /&gt;histogram / normal;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc reg data=samples WHERE SAMP=1 noprint;&lt;BR /&gt;by samp;&lt;BR /&gt;model y = x;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 22:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533100#M73812</guid>
      <dc:creator>khalillx</dc:creator>
      <dc:date>2019-02-05T22:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change my code to find that my model satisfies the assumption that E(U|X) = 0?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533101#M73813</link>
      <description>You can probably help us and yourself, i you indicate in your code (via comments) what you think each step is doing. You seem to understand what you want to do, but there's no link to your code as to which step is doing what.</description>
      <pubDate>Tue, 05 Feb 2019 22:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533101#M73813</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-05T22:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change my code to find that my model satisfies the assumption that E(U|X) = 0?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533102#M73814</link>
      <description>&lt;P&gt;I copied and pasted all my code into the question.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 22:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533102#M73814</guid>
      <dc:creator>khalillx</dc:creator>
      <dc:date>2019-02-05T22:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change my code to find that my model satisfies the assumption that E(U|X) = 0?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533308#M73823</link>
      <description>Your code has no comments. When you're coding commenting really does help you ensure your code is correct and it's a good habit to get into.</description>
      <pubDate>Wed, 06 Feb 2019 15:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-my-code-to-find-that-my-model-satisfies-the/m-p/533308#M73823</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-06T15:49:19Z</dc:date>
    </item>
  </channel>
</rss>

