<?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 Simulation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252434#M56829</link>
    <description>&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;I am trying to do a simulation but i am not sure how to do the code. &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;I have a linear equation &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;y=c+0.05X1+1.28X2&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;so here i am trying to obtain the values of y and b2 when I fix b1 first at 2 then 0 &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;How do i do that?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2016 17:04:20 GMT</pubDate>
    <dc:creator>kudamakoni100</dc:creator>
    <dc:date>2016-02-25T17:04:20Z</dc:date>
    <item>
      <title>Simulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252434#M56829</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;I am trying to do a simulation but i am not sure how to do the code. &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;I have a linear equation &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;y=c+0.05X1+1.28X2&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;so here i am trying to obtain the values of y and b2 when I fix b1 first at 2 then 0 &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="HelveticaNeue"&gt;&lt;SPAN&gt;How do i do that?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 17:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252434#M56829</guid>
      <dc:creator>kudamakoni100</dc:creator>
      <dc:date>2016-02-25T17:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252567#M56839</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/73162"&gt;@kudamakoni100﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like mathematical questions, but I'm a bit unsure what you mean by b1 and b2. Do these refer to the coefficients 0.05 and 1.28 in your equation? Or did you just mistype X1 and X2 (cf. &lt;A href="https://communities.sas.com/t5/SAS-Procedures/Basic-Simulation/m-p/249905#M56560" target="_blank"&gt;your post of 14 Feb&lt;/A&gt;)? And what can we assume about the ranges (or distributions?) of X1 and X2 and about c?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 22:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252567#M56839</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-25T22:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252616#M56845</link>
      <description>&lt;P&gt;Yes they refer to coefficients its a regression analysis&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 02:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252616#M56845</guid>
      <dc:creator>kudamakoni100</dc:creator>
      <dc:date>2016-02-26T02:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252778#M56857</link>
      <description>&lt;P&gt;Good to know it's a regression analysis. So, we have to simulate n data points (x1, x2, y), say, n=50.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume that x1 can vary in a range (x1min, x1max) and x2 in a range (x2min, x2max). You can define these ranges as appropriate. As you didn't make further assumptions about x1 and x2, it should be fine to simulate them as independent random samples from uniform distributions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You specified b1=2 for the first simulation and b1=0 for the second and in both cases&amp;nbsp;&lt;SPAN&gt;b2=1.28&lt;/SPAN&gt;. For simulating the y values, however, we need the remaining parameter, c, as well. In the code below it&amp;nbsp;is randomly selected from a uniform distribution on [-5, 5]. You can easily adapt this range to your needs. Moreover, we need to specify the standard deviation s&amp;gt;0 of the independent N(0,s)-distributed error terms (in the example: s=1), without which all data points would lie on the plane determined by the parameters, so that regression analysis would be pointless.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Simulation of linear regression model */

data simdata;
call streaminit(2718);    /* initialize random number generator */
b1=2;  * b1=0;            /* your choices for b1 */
b2=1.28;                  /* set b2 */
c=10*rand('uniform')-5;   /* set c arbitrarily */ 
n=50;                     /* number of observations */
x1min=-5; x1max=10;       /* range for x1 */
x2min= 3; x2max=8;        /* range for x2 */
s=1;                      /* err. std. dev. */
put (b1--s)(=);           /* write parameters to the log */
do i=1 to n;
  x1=x1min+(x1max-x1min)*rand('uniform');
  x2=x2min+(x2max-x2min)*rand('uniform');
  y=c+b1*x1+b2*x2+rand('normal',0,s);
  output;                 /* write simulated data to SIMDATA */
end;
keep y x1 x2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Alternatively, one could store the model parameters in a separate dataset and create only a view of the simulated data&lt;FONT face="arial,helvetica,sans-serif"&gt;:&lt;/FONT&gt; please see &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251457#M47519" target="_blank"&gt;this recent post&lt;/A&gt;&amp;nbsp;from Super User PGStats for an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To perform linear regression on the simulated data (which gives you the desired estimate of b2) and to obtain a prediction of y at a point (x1, x2) of your choice (in the example below I chose (4, 7)), you can use the following code (please omit the RESTRICT statement if you didn't mean to fix parameter value b1 in advance):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc reg data=simdata outest=est;
model y=x1 x2;
restrict x1=2; * x1=0;   /* your choices for b1 */
run;
quit;

data _null_;
x1=4;                   /* the x1 and x2 values for which */
x2=7;                   /* you want to predict y          */
set est(rename=(x1=b1 x2=b2 intercept=c));
y=c+b1*x1+b2*x2;
put 'Estimate of b2 = ' b2;
put 'Prediction at x1=' x1 'and x2=' x2 +(-1) ': y=' y;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please feel free to insert a calculation such as&amp;nbsp;&lt;FONT face="courier new,courier"&gt;y=c+b1*4+b2*7;&lt;/FONT&gt; into the simulation data step (before the line &lt;FONT face="courier new,courier"&gt;s=1;&lt;/FONT&gt;) so as to obtain the value of y for the true model parameters c, b1 and b2. You can then compare this value to the predicted value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, the above code uses b1=2. The case b1=0 is just commented out.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 18:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulation/m-p/252778#M56857</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-26T18:31:58Z</dc:date>
    </item>
  </channel>
</rss>

