<?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 to  simuluate a recursive formula in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463212#M3149</link>
    <description>&lt;P&gt;As soon as yt is missing, yt+1 will be missing also, and so on... The only way out is to prevent y from being missing. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data simulation; 
call streaminit(7556);
x = 50; 
do i = -50 to 100; 
    a = rand("normal");
    x = x + a - .6*x;
    output; 
    end; 
run; 

data sim2;
retain y 0;
set simulation;
y = coalesce (.95*lag1(y) - .225*lag2(y) + 1.0234*lag1(x) - .9*lag2(x) - .3*lag1(a) + a, 0);
if i &amp;gt; 0 then output;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 May 2018 04:59:02 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-05-18T04:59:02Z</dc:date>
    <item>
      <title>how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462798#M3140</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data table that I have created&amp;nbsp; using the following code&lt;/P&gt;&lt;PRE&gt;data simulation; 
 a1 = 0;
 x1 = 50; 
 seed = -2000;
 do i = -50 to 100; 
 a = rannor(seed);
 x = x1 + a - .6*x1;
 if i &amp;gt; 0 then output; 
 x1 = x; 
 a1 = a; 
 end; 
run; 
quit; &lt;BR /&gt;
proc arima data = simulation;
identify var = x nlag = 20;
estimate  p = 1 noint printall ;
/*identify var = y crosscorr = x nlag = 20;*/
forecast lead = 5 out = boxj;
run; 
quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dids2.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20571iB2D2BFDCFB7C4AE1/image-size/large?v=v2&amp;amp;px=999" role="button" title="dids2.JPG" alt="dids2.JPG" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to simulate a new variable y which relies on itself and x as such:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dids3.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20572i4BC3A928AB54D717/image-size/large?v=v2&amp;amp;px=999" role="button" title="dids3.JPG" alt="dids3.JPG" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to simulate this variable in SAS ? This is recursive and uses values of the already simulated variable x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 18:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462798#M3140</guid>
      <dc:creator>Dids</dc:creator>
      <dc:date>2018-05-16T18:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462867#M3141</link>
      <description>&lt;P&gt;Use the LAG1() and LAG2() functions.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 21:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462867#M3141</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-16T21:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462882#M3142</link>
      <description>&lt;P&gt;Thank you for your reply,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have never used the LAG functions. I am looking up examples and trying to fit them to my specific data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would this be along the lines of :&lt;BR /&gt;creating and assigning 4 new variables for yt - 1, yt-2, xt-1, xt - 2 ? then plugging them into my yt formula?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you know of good examples especially since I have Yt-k and Xt-k (two different variables)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 22:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462882#M3142</guid>
      <dc:creator>Dids</dc:creator>
      <dc:date>2018-05-16T22:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462924#M3143</link>
      <description>&lt;P&gt;This &lt;EM&gt;should&lt;/EM&gt; work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sim2;
retain y 0;
set boxj;
y = 123*lag1(y) - 976*lag2(y) + 0.879*lag1(x) - 7654*lag2(x) + 456*a - 234*lag1(a);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 04:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/462924#M3143</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-17T04:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463109#M3144</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;think you&amp;nbsp;will need to use the RETAIN statement and explicitly create your recursive lag variables for Y and A in order to simulate your data for Y.&amp;nbsp; Please see if the following allows you to obtain your desired result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data boxj(keep=x xl1 xl2);
  set boxj;                 /* output data set from PROC ARIMA step   */
  if x=. then x=forecast;   /* fill in missing X values with forecast */
  xl1=lag1(x); xl2=lag2(x); /* create lag1 and lag2 variables for X   */
run;

  /* simulate  yt = .95yt-1 - .225yt-2 + 1.0234xt-1 - .9xt-2 + at - .3at-1 */
data simy;
  set boxj(firstobs=3);     /* omit first 2 obs with missing Lag X values  */
  retain yl1 yl2 20 al1 0;  /* specify starting values for yl1, yl2, al1   */

  call streaminit(907356);  /* specify positive seed to reproduce results  */
  a=rand('normal');

  y = .95*yl1 - .225*yl2 + 1.0234*xl1 - .9*xl2 - .3*al1 + a;

  output;
  yl2=yl1; yl1=y; al1=a;  /*  generate recursive lag variables for y and a */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps!&lt;/P&gt;
&lt;P&gt;DW&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 19:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463109#M3144</guid>
      <dc:creator>dw_sas</dc:creator>
      <dc:date>2018-05-17T19:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463181#M3147</link>
      <description>&lt;P&gt;Hi PG,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately it gives null values for the created y variable. I am basically simulating a transfer function model (dynamic regressive model)&amp;nbsp; and I have the Yt formula as it is expanded by BoxJenkins...I wonder why it gives null values..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 22:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463181#M3147</guid>
      <dc:creator>Dids</dc:creator>
      <dc:date>2018-05-17T22:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463194#M3148</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203394"&gt;@Dids&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi PG,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the help,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately it gives null values for the created y variable. I am basically simulating a transfer function model (dynamic regressive model)&amp;nbsp; and I have the Yt formula as it is expanded by BoxJenkins...I wonder why it gives null values..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again Thank you&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Probably because you do not have any value of Y for the first record or two. If the formula is to look at two prior periods and they are missing then expect the result to be missing. "Recursion" has to start with something.&lt;/P&gt;
&lt;P&gt;Example: &lt;STRONG&gt;Fibonacci sequence&lt;/STRONG&gt;, and characterized by the fact that every number &lt;STRONG&gt;after the first two&lt;/STRONG&gt; is the sum of the two preceding ones.&lt;/P&gt;
&lt;P&gt;Values are defined as:&lt;/P&gt;
&lt;P&gt;&lt;IMG class="mwe-math-fallback-image-inline" style="width: 18.92ex; height: 2.5ex; vertical-align: -0.67ex;" alt="{\displaystyle F_{n}=F_{n-1}+F_{n-2},}" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0fff1a1716fcc169546079870357f92757ade5fa" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;with &lt;A title="Seed value" class="mw-redirect" href="https://en.wikipedia.org/wiki/Seed_value" target="_blank"&gt;seed values&lt;/A&gt;&lt;/P&gt;
&lt;DL&gt;
&lt;DD&gt;&lt;SPAN class="mwe-math-element"&gt;&lt;SPAN class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"&gt;F 1 = 1 , F 2 = 1 {\displaystyle F_{1}=1,\;F_{2}=1} &lt;/SPAN&gt;&lt;IMG class="mwe-math-fallback-image-inline" style="width: 15.29ex; height: 2.5ex; vertical-align: -0.67ex;" alt="{\displaystyle F_{1}=1,\;F_{2}=1}" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4e5717c664395faf20231a2e5bbe561960e055b0" border="0" /&gt;&lt;/SPAN&gt;&lt;/DD&gt;
&lt;/DL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="mwe-math-element"&gt;So you need a seed or starting values of Y for the first two records in your data. Since you have never mentioned if Y is one of the results shown that's about as far as I can get on this particular issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 23:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463194#M3148</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-17T23:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463212#M3149</link>
      <description>&lt;P&gt;As soon as yt is missing, yt+1 will be missing also, and so on... The only way out is to prevent y from being missing. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data simulation; 
call streaminit(7556);
x = 50; 
do i = -50 to 100; 
    a = rand("normal");
    x = x + a - .6*x;
    output; 
    end; 
run; 

data sim2;
retain y 0;
set simulation;
y = coalesce (.95*lag1(y) - .225*lag2(y) + 1.0234*lag1(x) - .9*lag2(x) - .3*lag1(a) + a, 0);
if i &amp;gt; 0 then output;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 04:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463212#M3149</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-18T04:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to  simuluate a recursive formula</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463452#M3154</link>
      <description>&lt;P&gt;Hi DW&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&amp;nbsp; this does seem to do the job. I am going to run it with different Arima models and see if I am getting close to my goal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is greatly appreciated&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 22:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/how-to-simuluate-a-recursive-formula/m-p/463452#M3154</guid>
      <dc:creator>Dids</dc:creator>
      <dc:date>2018-05-18T22:00:59Z</dc:date>
    </item>
  </channel>
</rss>

