<?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: PROC UCM: Forecast in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/PROC-UCM-Forecast/m-p/409257#M2761</link>
    <description>&lt;P&gt;Your question has many parts.&amp;nbsp; I am going to answer the part about the computation of rolling forecasts.&amp;nbsp; What to do with these rolling forecasts is up to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently there is no option in the UCM procedure to produce rolling forecasts.&amp;nbsp;&amp;nbsp;Until such an option becomes available, one must resort to repeated calls to UCM (quite inefficient and tedious).&amp;nbsp; I am going to illustrate&amp;nbsp;one such way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First some notation.&amp;nbsp; Suppose we have N measurements on a response variable y: y_1, y_2, ..., y_N.&amp;nbsp; For h &amp;gt;= 1, let F(t,h) denote the h-step-ahead forecast of y_(t+h) using data y_1, y_2, ..., y_t.&amp;nbsp; When (t+h) &amp;lt;= N, let E(t,h) = y_(t+h) - F(t,h) denote the (in-sample) h-step-ahead residual.&amp;nbsp; The UCM procedure provides one-step-ahead (h=1) forecasts and residuals, F(t,1) and E(t,1), for many time instances t within the historical period by default.&amp;nbsp; However, the in-sample multi-step-ahead forecasts and residuals &lt;BR /&gt;(F(t,h) and E(t,h) for h &amp;gt; 1) are NOT provided for different time instances.&amp;nbsp; The computation of rolling forecasts (and residuals) involves computation of F(t,h) and E(t,h) for various t and h combinations where (t+h) &amp;lt;= N.&amp;nbsp; Unfortunately, at the moment there is no simple option to output all possible rolling forecasts in a single UCM call.&amp;nbsp;&amp;nbsp;&amp;nbsp; On the other hand, you can make repeated UCM calls with different holdout periods (BACK= option in the FORECAST statement) to get the necessary rolling forecasts.&amp;nbsp; When you use BACK=k, you get F(N-k, h) and E(N-k,h) for h=1, 2,..,k.&amp;nbsp; Of course, this is not a very efficient way to get the rolling forecasts.&amp;nbsp; But at the moment this is the simplest way I can think of.&amp;nbsp; The "roll" macro given below provides an illustration.&amp;nbsp; The "roll" macro makes repeated calls to UCM to create a large data set--finalFor--that contains the rolling forecasts.&amp;nbsp; Actually, finalFor must be processed further to extract the rolling forecasts.&amp;nbsp; For example, the last k values of for k column in finalFor correspond to F(N-k, h) for h=1, 2, ..,k.&amp;nbsp; You can then rearrange these numbers: for example, collect all 3-step ahead forecasts in a new&amp;nbsp;data set.&amp;nbsp; It does get tedious but the necessary numbers are in the output table finalFor.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*------- illustration ---------*/&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/* estimate model parameters */&lt;BR /&gt;proc ucm data=sashelp.air;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; id date interval=month;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; model air;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; irregular;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; level;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; slope variance=0 noest;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let start = 5;&lt;BR /&gt;%let end = 6;&lt;BR /&gt;%macro roll;&lt;BR /&gt;%do k=&amp;amp;start %to &amp;amp;end; /* different values of BACK= option */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* model parameters from the earlier call */&lt;BR /&gt;&amp;nbsp;proc ucm data=sashelp.air;* noprint;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id date interval=month;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model air;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; irregular variance=0.00027444 noest;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; level variance=1139.35114 noest;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; slope variance=0 noest;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; forecast back=&amp;amp;k lead=&amp;amp;k outfor=for;&lt;BR /&gt;&amp;nbsp;run;&lt;BR /&gt;&amp;nbsp;data rfor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set for(keep=date air forecast residual std);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for_&amp;amp;k = forecast;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; std_&amp;amp;k = std;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; residual_&amp;amp;k = residual;&lt;BR /&gt;&amp;nbsp;run;&lt;BR /&gt;&amp;nbsp;%if &amp;amp;k = 5 %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data finalFor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set rfor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;&amp;nbsp;%else %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data finalFor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge rfor finalFor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%roll;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Oct 2017 18:22:09 GMT</pubDate>
    <dc:creator>rselukar</dc:creator>
    <dc:date>2017-10-31T18:22:09Z</dc:date>
    <item>
      <title>PROC UCM: Forecast</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/PROC-UCM-Forecast/m-p/408797#M2750</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to&amp;nbsp;run o&lt;SPAN&gt;ut-of-sample forecasts with rolling regressions for N countries from September 2008 to August 2017 *************;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;********************************************************* Data Set *****************************************&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* My dataset is panel monthly data with 10 countries&lt;/P&gt;&lt;P&gt;* Sample period:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;From December 1996 to August 2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example to show my data set.&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Country&amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; Number&amp;nbsp; &amp;nbsp; &amp;nbsp; Observation&lt;/P&gt;&lt;P&gt;12/31/1996&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;01/31/1997&amp;nbsp; &amp;nbsp; &amp;nbsp; Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;08/31/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;250&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;12/31/1996&amp;nbsp; &amp;nbsp; &amp;nbsp;Canada&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;........&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;08/31/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 250&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;12/31/1996&amp;nbsp; &amp;nbsp; &amp;nbsp;UK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;08/31/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;UK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;250&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;****************** Modified Data set ********************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I modified the above data set by creating a new date variable called 'Rankdate'&amp;nbsp;&lt;/SPAN&gt;that shows the ending date in each rolling regression, as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Rankdate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Country&amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Number&amp;nbsp; &amp;nbsp; &amp;nbsp; Observations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;August 2008&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12/31/1996&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;August 2008&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/31/1997&amp;nbsp; &amp;nbsp; &amp;nbsp; Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;August 2008&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; 08/31/2008&amp;nbsp; &amp;nbsp; &amp;nbsp; Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;September 2008&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/1997&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;September 2008&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09/30/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;...................&lt;/P&gt;&lt;P&gt;.....................&lt;/P&gt;&lt;P&gt;August 2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;12/31/2005&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;............&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;August 2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08/30/2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Australia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;August 2008&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12/31/1996&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Canada&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;........&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;August 2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;08/31/2017&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;************************************ Goal: Run Recursive Regression ************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;* I want to run several recursive regressions for EACH country (i.e. keeps the starting date (i.e., December 1996) fixed,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then adding an observation to the end of the sample with every run of&amp;nbsp;the regression).&lt;BR /&gt;More specifically, I run the following sas code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC UCM DATA = ma.developingrank(where=(country='CZ')); BY rankdate;&lt;BR /&gt;ID DATE INTERVAL=MONTH;&lt;BR /&gt;MODEL RETURN = MA;&lt;BR /&gt;IRREGULAR;&lt;BR /&gt;level var=0;&lt;BR /&gt;estimate back=1 outest=ma.OOSRollEst1;*The default is BACK=0,&lt;BR /&gt;which means that the forecast starts at the end of the available data;&lt;BR /&gt;FORECAST back=1 LEAD=1 outfor=ma.OOSRollRes1 plot=forecasts;&lt;BR /&gt;*forecast span;*This reports the one-step ahead out-of-sample forecast;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My problem, however, is&amp;nbsp;that the above code gives me forecast for each rolling window, and I don't know which model to report in my paper, and HOW?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your help in advance.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 16:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/PROC-UCM-Forecast/m-p/408797#M2750</guid>
      <dc:creator>Yamani</dc:creator>
      <dc:date>2017-10-30T16:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC UCM: Forecast</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/PROC-UCM-Forecast/m-p/409257#M2761</link>
      <description>&lt;P&gt;Your question has many parts.&amp;nbsp; I am going to answer the part about the computation of rolling forecasts.&amp;nbsp; What to do with these rolling forecasts is up to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently there is no option in the UCM procedure to produce rolling forecasts.&amp;nbsp;&amp;nbsp;Until such an option becomes available, one must resort to repeated calls to UCM (quite inefficient and tedious).&amp;nbsp; I am going to illustrate&amp;nbsp;one such way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First some notation.&amp;nbsp; Suppose we have N measurements on a response variable y: y_1, y_2, ..., y_N.&amp;nbsp; For h &amp;gt;= 1, let F(t,h) denote the h-step-ahead forecast of y_(t+h) using data y_1, y_2, ..., y_t.&amp;nbsp; When (t+h) &amp;lt;= N, let E(t,h) = y_(t+h) - F(t,h) denote the (in-sample) h-step-ahead residual.&amp;nbsp; The UCM procedure provides one-step-ahead (h=1) forecasts and residuals, F(t,1) and E(t,1), for many time instances t within the historical period by default.&amp;nbsp; However, the in-sample multi-step-ahead forecasts and residuals &lt;BR /&gt;(F(t,h) and E(t,h) for h &amp;gt; 1) are NOT provided for different time instances.&amp;nbsp; The computation of rolling forecasts (and residuals) involves computation of F(t,h) and E(t,h) for various t and h combinations where (t+h) &amp;lt;= N.&amp;nbsp; Unfortunately, at the moment there is no simple option to output all possible rolling forecasts in a single UCM call.&amp;nbsp;&amp;nbsp;&amp;nbsp; On the other hand, you can make repeated UCM calls with different holdout periods (BACK= option in the FORECAST statement) to get the necessary rolling forecasts.&amp;nbsp; When you use BACK=k, you get F(N-k, h) and E(N-k,h) for h=1, 2,..,k.&amp;nbsp; Of course, this is not a very efficient way to get the rolling forecasts.&amp;nbsp; But at the moment this is the simplest way I can think of.&amp;nbsp; The "roll" macro given below provides an illustration.&amp;nbsp; The "roll" macro makes repeated calls to UCM to create a large data set--finalFor--that contains the rolling forecasts.&amp;nbsp; Actually, finalFor must be processed further to extract the rolling forecasts.&amp;nbsp; For example, the last k values of for k column in finalFor correspond to F(N-k, h) for h=1, 2, ..,k.&amp;nbsp; You can then rearrange these numbers: for example, collect all 3-step ahead forecasts in a new&amp;nbsp;data set.&amp;nbsp; It does get tedious but the necessary numbers are in the output table finalFor.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*------- illustration ---------*/&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/* estimate model parameters */&lt;BR /&gt;proc ucm data=sashelp.air;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; id date interval=month;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; model air;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; irregular;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; level;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; slope variance=0 noest;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let start = 5;&lt;BR /&gt;%let end = 6;&lt;BR /&gt;%macro roll;&lt;BR /&gt;%do k=&amp;amp;start %to &amp;amp;end; /* different values of BACK= option */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* model parameters from the earlier call */&lt;BR /&gt;&amp;nbsp;proc ucm data=sashelp.air;* noprint;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id date interval=month;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model air;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; irregular variance=0.00027444 noest;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; level variance=1139.35114 noest;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; slope variance=0 noest;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; forecast back=&amp;amp;k lead=&amp;amp;k outfor=for;&lt;BR /&gt;&amp;nbsp;run;&lt;BR /&gt;&amp;nbsp;data rfor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set for(keep=date air forecast residual std);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for_&amp;amp;k = forecast;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; std_&amp;amp;k = std;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; residual_&amp;amp;k = residual;&lt;BR /&gt;&amp;nbsp;run;&lt;BR /&gt;&amp;nbsp;%if &amp;amp;k = 5 %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data finalFor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set rfor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;&amp;nbsp;%else %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data finalFor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge rfor finalFor;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%roll;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 18:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/PROC-UCM-Forecast/m-p/409257#M2761</guid>
      <dc:creator>rselukar</dc:creator>
      <dc:date>2017-10-31T18:22:09Z</dc:date>
    </item>
  </channel>
</rss>

