VARMAX Procedure

Example 42.5 Conditional Forecasts and Scenario Analysis

(View the complete code for this example.)

Conditional forecasts incorporate future information and the uncertainty of parameters in the forecasts, and they often provide more accurate forecasts than unconditional forecasts do. Clark and McCracken (2017) evaluate conditional forecasts and focus on tests of bias, efficiency, and equal accuracy applied to conditional forecasts from VAR models. In this example, a Monte Carlo experiment is created in order to compare different types of forecasts; that is, 1,000 data sets are generated and the following forecasts are compared: equation-based unconditional forecasts, simulation-based unconditional forecasts, simulation-based conditional forecasts under hard conditions, and simulation-based conditional forecasts under soft conditions.

Consider the following trivariate VAR(2) model:

bold y Subscript t Baseline equals bold c plus bold upper A 1 bold y Subscript t minus 1 Baseline plus bold upper A 2 bold y Subscript t minus 2 Baseline plus bold-italic epsilon Subscript t Baseline comma bold-italic epsilon Subscript t Baseline tilde upper N left-parenthesis 0 comma normal upper Sigma right-parenthesis

where

bold c equals Start 3 By 1 Matrix 1st Row  2.425 2nd Row  0.054 3rd Row  negative 0.110 EndMatrix comma bold upper A 1 equals Start 3 By 3 Matrix 1st Row 1st Column 0.234 2nd Column negative 0.134 3rd Column negative 0.057 2nd Row 1st Column 0.029 2nd Column 0.575 3rd Column 0.200 3rd Row 1st Column 0.059 2nd Column 0.038 3rd Column 1.006 EndMatrix
bold upper A 2 equals Start 3 By 3 Matrix 1st Row 1st Column 0.164 2nd Column negative 0.150 3rd Column negative 0.165 2nd Row 1st Column negative 0.039 2nd Column 0.138 3rd Column negative 0.184 3rd Row 1st Column 0.031 2nd Column 0.019 3rd Column negative 0.087 EndMatrix comma normal upper Sigma equals Start 3 By 3 Matrix 1st Row 1st Column 9.265 2nd Column 0.296 3rd Column 0.553 2nd Row 1st Column 0.296 2nd Column 1.746 3rd Column 0.184 3rd Row 1st Column 0.553 2nd Column 0.184 3rd Column 0.752 EndMatrix

As indicated in Clark and McCracken (2017), the parameter values are equal to the OLS (ordinary least squares) estimates of a VAR in GDP (gross domestic product) growth, inflation less a survey-based measure of trend inflation, and the federal funds rate less a survey-based measure of trend, over a sample from 1961 to 2007. Many central banks require forecasts conditional on particular paths of policy instruments. This example analyzes different scenarios of some known future information on the third variable that is related to federal funds rate.

Conditional Forecasts and Scenario Analysis under Hard Conditions

This section considers the hard conditions, under which some future dependent variables are fixed to some single values.

The following macro generates the data for analysis:

title 'Conditional Forecasts and Scenario Analysis';
%macro cfSimulateData(dgpi,T,lead,tblDGP,tblSample);
   * dgpi: index of DGP;
   * T: in-sample sample size;
   * lead: future horizons;
   * tblDGP: output table name for full-sample data;
   * tblSample: output table name for in-sample data;
   proc iml;
      * simulate the data;
      * trivariate VAR(2) model;
      seed = 12345 + &dgpi.; * random seed;
      n = 3;                 * dim of dependent variable;
      T = &T.;               * in-sample sample size;
      lead = &lead.;         * future horizons;
      p = 2;                 * AR order;
      * parameter values;
      const = {2.425, 0.054, -0.110};
      phi   = {0.234 -0.134 -0.057,
               0.029  0.575  0.200,
               0.059  0.038  1.006,
               0.164 -0.150 -0.165,
              -0.039  0.138 -0.184,
               0.031  0.019 -0.087};
      sigma = {9.265  0.296  0.553,
               0.296  1.746  0.184,
               0.553  0.184  0.752};
      call varmasim(y,phi) sigma = sigma n = T+lead seed = seed;
      mu = (inv(I(3)-phi[1:3,]-phi[4:6,])*const)`;
      y = y + mu;
      name={y1 y2 y3};
      create &tblDGP. from y[colname=name];
      append from y;
      close;
   quit;
   data &tblSample.; set &tblDGP.(obs=&T.); run;
%mend;

The following macro constructs four scenarios that contain hard conditions. In scenario i comma i equals 1 comma ellipsis comma 4, the first i future values of y3 are fixed (to their true values). In the real world, the true future values cannot be known. Here, the true future values are used so that you can check later whether using more information results in any advantage in conditional forecasts.

%macro hcConstructScenarios(T,tblDGP,tblScenarios);
   * T: in-sample sample size;
   * tblDGP: input table name for full-sample data;
   * tblScenarios: output table name for scenarios;
   data &tblScenarios.;
      set &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+1))
          &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+2))
          &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+3))
          &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+4))
          &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+1));
      * scenario 1: y3(1) is known;
      if(_N_=1) then do;
         y1=.; y2=.; myscenario=1;
      end;
      * scenario 2: y3(1:2) is known;
      if(_N_>1 and _N_<=3) then do;
         y1=.; y2=.; myscenario=2;
      end;
      * scenario 3: y3(1:3) is known;
      if(_N_>3 and _N_<=6) then do;
         y1=.; y2=.; myscenario=3;
      end;
      * scenario 4: y3(1:4) is known;
      if(_N_>6 and _N_<=10) then do;
         y1=.; y2=.; myscenario=4;
      end;
      * scenario 5: nothing is known (unconditional forecast);
      if(_N_>10) then do;
         y1=.; y2=.; y3=.; myscenario=5;
      end;
   run;
%mend;

The following macro estimates and performs several types of forecasts. The equation-based forecasts are output to the OUT= data set that is specified in the OUTPUT statement. The conditional forecasts for scenarios 1 to 4 and the unconditional forecasts (for scenario 5) are output to the OUT= data set that is specified in the CONDFORE statement.

%macro hcEstimateAndForecast(tblSample,tblScenarios,alpha,lead,nmc,
   tblF,tblCf,tblCfSim);
   * tblSample: input table name for in-sample data;
   * tblScenarios: input table name for scenarios;
   * alpha: size of the confidence interval or credible interval;
   * lead: future horizons;
   * nmc: number of Monte Carlo iterations;
   * tblF: output table name of equation-based point and interval forecasts;
   * tblCf: output table name of conditionial point and interval forecasts;
   * tblCfSim: output table name of simulated conditional forecasts;
   proc varmax data=&tblSample.;
      model y1 - y3 / p=2 prior noprint;
      output alpha=&alpha. lead=&lead. out=&tblF. noprint;
      condfore alpha=&alpha. lead=&lead. out=&tblCf. outsim=&tblCfSim.
         sdata=&tblScenarios. sid=myscenario
         parm=sampling(scenario) nbi=1000 nmc=&nmc.;
   run;
%mend;

The following macro saves all types of forecasts for one simulated data set to one data set for evaluation:

%macro hcSaveForecasts(dgpi,T,lead,nScenarios,tblDGP,tblF,tblCf,tblAll);
   * dgpi: index of DGP;
   * T: in-sample sample size;
   * lead: future horizons;
   * nScenarios: number of scenarios;
   * tblDGP: input table name for full-sample data;
   * tblF: input table name of equation-based point and interval forecasts;
   * tblCf: input table name of conditionial point and interval forecasts;
   * tblAll: output table name of point and interval forecasts for all DGPs;
   data forecasts;
      set &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+&lead.) keep=Y1 Y2);
      * for notation convenience, name equation-based forecasts as S0;
      set &tblF.(firstobs=%eval(&T.+1) obs=%eval(&T.+&lead.)
         rename=( for1=Y1_S0 for2=Y2_S0
                  lci1=Y1_LB_S0 uci1=Y1_UB_S0
                  lci2=Y2_LB_S0 uci2=Y2_UB_S0)
         keep=FOR1 LCI1 UCI1 FOR2 LCI2 UCI2);
      %do i = 1 %to &nScenarios.;
         set &tblCf.(where=(myscenario_S&i.=&i.)
            rename=( Y1_MEDIAN=Y1_S&i. Y2_MEDIAN=Y2_S&i.
                     Y1_LB=Y1_LB_S&i. Y1_UB=Y1_UB_S&i.
                     Y2_LB=Y2_LB_S&i. Y2_UB=Y2_UB_S&i.
                     myscenario=myscenario_S&i.)
            keep=myscenario Y1_MEDIAN Y2_MEDIAN Y1_LB Y1_UB Y2_LB Y2_UB);
      %end;
      dgpIndex = &dgpi.;
      h = _N_;
      drop myscenario_S1 - myscenario_S&nScenarios.;
   run;
   proc append base=&tblAll. data=forecasts; run;
%mend;

The following macro evaluates the forecasts from different methods and under different conditions. The accuracy of point forecasts is measured through the symmetric mean absolute percentage error (sMAPE), which is used in the M4 Forecasting Competition. The sMAPE is defined as

normal s normal upper M normal upper A normal upper P normal upper E equals StartFraction 1 Over h EndFraction sigma-summation Underscript i equals 1 Overscript h Endscripts StartFraction 2 StartAbsoluteValue bold y Subscript upper T plus i Baseline minus ModifyingAbove bold y With caret Subscript upper T plus i Baseline EndAbsoluteValue Over StartAbsoluteValue bold y Subscript upper T plus i Baseline EndAbsoluteValue plus StartAbsoluteValue ModifyingAbove bold y With caret Subscript upper T plus i Baseline EndAbsoluteValue EndFraction

where T is the in-sample sample size, bold y Subscript upper T plus i is the future value at upper T plus i, ModifyingAbove bold y With caret Subscript upper T plus i is the ith-step-ahead forecast, and h is the forecasting horizon. The smaller the sMAPE, the better the forecasting method. In order to easily compare the sMAPEs, the relative sMAPEs are calculated. The simulation-based unconditional forecasts are used as the benchmark. As for the interval forecasts (that is, the confidence interval for equation-based forecasts and the credible interval for simulation-based conditional and unconditional forecasts), first the size is checked, and then the lengths of intervals are compared: if the size is correct, the smaller the interval length, the more accurate and better the forecasting method.

%macro cfEvaluate(tblAll,lead,nSim,nScenarios,qScenario0,scenarioBM,tblEval);
   * tblAll: input table name of point and interval forecasts for all DGPs;
   * lead: future horizons;
   * nSim: number of DGPs;
   * nScenarios: number of scenarios;
   * qScenario0: whether there is S0 for equation-based forecasts,
                 1 for yes and 0 for no;
   * scenarioBM: the index of the benchmark scenario;
   * tblEval: output table name for evaluation results;
   proc iml;
      use &tblAll.;
      read all into d;
      close;
      lead = &lead.;
      nSim = &nSim.;
      nScenarios = &nScenarios. + &qScenario0.;
      scenarioBM = &scenarioBM.;
      nVars = 2;
      sMAPE = J(lead,nScenarios*nVars,0);
      rsMAPE = J(lead,nScenarios*nVars,0);
      sizeCI = J(lead,nScenarios*nVars,0);
      rLenCI = J(lead,nScenarios*nVars,0);
      do iSim = 1 to nSim;
         do h = 1 to lead;
            do iScenario = 1 to nScenarios;
               do iVar = 1 to nVars;
                  yF=d[(iSim-1)*lead+h,
                       nVars+((iScenario-1)*nVars+(iVar-1))*3+1];
                  yFlb=d[(iSim-1)*lead+h,
                         nVars+((iScenario-1)*nVars+(iVar-1))*3+2];
                  yFub=d[(iSim-1)*lead+h,
                         nVars+((iScenario-1)*nVars+(iVar-1))*3+3];
                  yFlbBM=d[(iSim-1)*lead+h,
                           nVars+((scenarioBM-1)*nVars+(iVar-1))*3+2];
                  yFubBM=d[(iSim-1)*lead+h,
                           nVars+((scenarioBM-1)*nVars+(iVar-1))*3+3];
                  y =d[(iSim-1)*lead+h,iVar];
                  * symmetric Mean Absolute Percentage Error (sMAPE);
                  if(abs(yF)+abs(y)>0) then do;
                     sMAPE[h,(iVar-1)*nScenarios+iScenario] =
                        sMAPE[h,(iVar-1)*nScenarios+iScenario]
                           + 2*abs(yF-y)/(abs(yF)+abs(y))/nSim;
                  end;
                  * size;
                  if(y>=yFlb & y<=yFub) then do;
                     sizeCI[h,(iVar-1)*nScenarios+iScenario] =
                        sizeCI[h,(iVar-1)*nScenarios+iScenario] + 1/nSim;
                  end;
                  * relative length;
                  if(yFubBM-yFlbBM>0) then do;
                     rLenCI[h,(iVar-1)*nScenarios+iScenario] =
                        rLenCI[h,(iVar-1)*nScenarios+iScenario]
                           + (yFub-yFlb)/(yFubBM-yFlbBM)/nSim;
                  end;
               end;
            end;
         end;
      end;
      do h = 2 to lead;
         do iScenario = 1 to nScenarios;
            do iVar = 1 to nVars;
               sMAPE[h,(iVar-1)*nScenarios+iScenario] =
                  (sMAPE[h,(iVar-1)*nScenarios+iScenario]
                     + sMAPE[h-1,(iVar-1)*nScenarios+iScenario]*(h-1))/h;
            end;
         end;
      end;
      do h = 1 to lead;
         do iScenario = 1 to nScenarios;
            do iVar = 1 to nVars;
               * relative symmetric Mean Absolute Percentage Error;
               rsMAPE[h,(iVar-1)*nScenarios+iScenario] =
                  sMAPE[h,(iVar-1)*nScenarios+iScenario]
                     / sMAPE[h,(iVar-1)*nScenarios+scenarioBM];
            end;
         end;
      end;

      * rearrange results;
      n = ncol(sMAPE)/nVars;
      evalResult = sMAPE[,1:n];
      do iVar = 2 to nVars;
         evalResult = evalResult // sMAPE[,(iVar-1)*n+1:iVar*n];
      end;
      do iVar = 1 to nVars;
         evalResult = evalResult // rsMAPE[,(iVar-1)*n+1:iVar*n];
      end;
      do iVar = 1 to nVars;
         evalResult = evalResult // sizeCI[,(iVar-1)*n+1:iVar*n];
      end;
      do iVar = 1 to nVars;
         evalResult = evalResult // rLenCI[,(iVar-1)*n+1:iVar*n];
      end;
      evalResult = ((1:4)`@J(lead*nVars,1,1))
                || (J(4,1,1)@((1:nVars)`@J(lead,1,1)))
                || (J(4*nVars,1,1)@(1:lead)`)
                || evalResult;
      create &tblEval. from evalResult;
      append from evalResult;
      close;
   quit;
%mend;

The following macro incorporates all the previous macros to test the forecasts from different methods (equation-based versus simulation-based) for different scenarios (unconditional versus four types of hard conditions). All point and interval forecasts are saved in the data set that is specified by the tblAll argument. All evaluation results are saved in the data set that is specified by the tblEval argument.

%macro hcTest(nSim,T,lead,alpha,nmc,nScenarios,qScenario0,scenarioBM,
   tblAll,tblEval);
   * nSim: number of DGPs;
   * T: in-sample sample size;
   * lead: future horizons;
   * alpha: size of the confidence interval or credible interval;
   * nmc: number of Monte Carlo iterations;
   * nScenarios: number of scenarios;
   * qScenario0: whether there is scenario 0 for equation-based forecasts,
                 1 for yes and 0 for no;
   * scenarioBM: the index of the benchmark scenario;
   * tblAll: output table name of point and interval forecasts for all DGPs;
   * tblEval: output table name for evaluation results;
   %do iSim = 1 %to &nSim.;
      %cfSimulateData(&iSim.,&T.,&lead.,t1,t2);
      %hcConstructScenarios(&T.,t1,t3);
      %hcEstimateAndForecast(t2,t3,&alpha.,&lead.,&nmc.,of,ocf,ocfsim);
      %hcSaveForecasts(&iSim.,&T.,&lead.,&nScenarios.,t1,of,ocf,&tblAll.);
   %end;
   %cfEvaluate(&tblAll.,&lead.,&nSim.,
               &nScenarios.,&qScenario0.,&scenarioBM.,
               &tblEval.);
%mend;

The following macro variables and macro set up and perform the test:

%let nSim = 1000;
%let T = 200;
%let lead = 4;
%let alpha = 0.05;
%let nmc = 10000;
%let nScenarios = 5;
%let qScenario0 = 1;
%let scenarioBM = 6;
%hcTest(&nSim.,&T.,&lead.,&alpha.,&nmc.,
        &nScenarios.,&qScenario0.,&scenarioBM.,
        hcForecasts,hcEval);

In order to show the result in a good style, the following template is created and the macro applies the template to the data set:

proc template;
   define table hcEvalTemplate;
      column col3 col4 col5 col6 col7 col8 col9;
      define header hc;
         text "Conditional Forecasts, Hard Conditions";
         start=col5; end=col8;
      end;
      define column col3;
         header="Horizon";
      end;
      define column col4;
         header="Equation Based"; format=7.5;
      end;
      define column col5;
         header="Scenario 1"; format=12.5;
      end;
      define column col6;
         header="Scenario 2"; format=12.5;
      end;
      define column col7;
         header="Scenario 3"; format=12.5;
      end;
      define column col8;
         header="Scenario 4"; format=12.5;
      end;
      define column col9;
         header="Unconditional"; format=12.5;
      end;
   end;
run;
%macro cfPrint(template,data);
   data _NULL_;
      set &data.;
      file print ods=(template="&template.");
      put _ODS_;
   run;
%mend;

The following macro calls print the sMAPEs for y1 and y2. Output 42.5.1 and Output 42.5.2 show that as more future information from scenario 1 to 4 is used in the conditional forecasts, the sMAPEs get smaller, which means that the accuracy of forecasts gets better.

%cfPrint(hcEvalTemplate, hcEval(where=(col1=1 and col2=1)));
%cfPrint(hcEvalTemplate, hcEval(where=(col1=1 and col2=2)));

Output 42.5.1: The sMAPEs for y1

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.903070.901010.897940.898740.894190.90146
20.884740.880550.877370.874710.872340.88451
30.876740.872430.873090.868220.866640.87632
40.869080.865530.865530.862660.861290.86954


Output 42.5.2: The sMAPEs for y2

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
11.078951.068671.070271.070531.069771.07941
21.161521.147041.151811.145941.144411.16143
31.222601.214871.213971.200501.195481.22251
41.271061.268421.263921.252771.240371.27112


The following macro calls print the relative sMAPEs for y1 and y2. Output 42.5.3 and Output 42.5.4 show that the relative sMAPE for all conditional point forecasts is less than 1, which means that all of them have better accuracy than the benchmark unconditional forecasts. The relative sMAPE for equation-based point forecasts is very close to 1, which means that the accuracy of the equation-based forecasts is similar to that of unconditional forecasts.

%cfPrint(hcEvalTemplate, hcEval(where=(col1=2 and col2=1)));
%cfPrint(hcEvalTemplate, hcEval(where=(col1=2 and col2=2)));

Output 42.5.3: The Relative sMAPEs for y1

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
11.001790.999510.996100.996980.991941.00000
21.000260.995520.991930.988920.986241.00000
31.000480.995560.996320.990760.988961.00000
40.999480.995400.995390.992090.990521.00000


Output 42.5.4: The Relative sMAPEs for y2

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.999580.990050.991530.991770.991071.00000
21.000080.987600.991720.986660.985341.00000
31.000080.993750.993020.982000.977891.00000
40.999950.997880.994340.985560.975811.00000


The following macro calls print the sizes for y1 and y2. Output 42.5.5 and Output 42.5.6 show that the sizes for all forecasts are very close to 0.95, which means all forecasts have the correct sizes.

%cfPrint(hcEvalTemplate, hcEval(where=(col1=3 and col2=1)));
%cfPrint(hcEvalTemplate, hcEval(where=(col1=3 and col2=2)));

Output 42.5.5: The Sizes for y1

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.947000.943000.936000.945000.948000.94400
20.949000.947000.941000.946000.947000.95000
30.951000.946000.943000.950000.953000.95200
40.944000.947000.945000.948000.942000.93800


Output 42.5.6: The Sizes for y2

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.954000.951000.947000.944000.947000.94600
20.950000.943000.941000.942000.932000.94900
30.949000.949000.946000.944000.943000.94200
40.941000.941000.937000.942000.944000.94500


The following macro calls print the relative interval lengths for y1 and y2. Output 42.5.7 and Output 42.5.8 show that almost all conditional forecasts show smaller relative interval length than the benchmark unconditional forecasts show, which means that the conditional forecasts have better interval forecasts than unconditional forecasts. The relative interval lengths for equation-based forecasts are all greater than 1, which means that equation-based forecasts have worse interval forecasting ability than unconditional forecasts have. The main reason might be that the unconditional forecasts account for the uncertainty of parameters but equation-based forecasts do not.

%cfPrint(hcEvalTemplate, hcEval(where=(col1=4 and col2=1)));
%cfPrint(hcEvalTemplate, hcEval(where=(col1=4 and col2=2)));

Output 42.5.7: The Relative Interval Lengths for y1

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
11.022900.992100.956160.950640.964771.00000
21.008141.000500.958010.949820.940941.00000
31.013480.985990.996130.970290.955201.00000
41.017541.005820.991471.008970.965891.00000


Output 42.5.8: The Relative Interval Lengths for y2

Conditional Forecasts and Scenario Analysis

HorizonEquation BasedConditional Forecasts, Hard ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
11.029901.000100.995270.974680.980161.00000
21.027720.987910.969350.970000.954311.00000
31.036131.014150.973970.974720.957151.00000
41.019180.979800.963140.964610.952981.00000


Conditional Forecasts and Scenario Analysis under Soft Conditions

This section considers the soft conditions, under which some future dependent variables are bounded within certain ranges instead of fixed to some single values.

The following macro estimates the model and outputs the unconditional forecasts. In the case of soft conditions, only the unconditional forecasts are needed. When the SDATA= option in the CONDFORE statement is not specified, unconditional forecasts are generated. The number of Monte Carlo iterations needs to be large because later the simulated forecasts that satisfy the soft conditions are selected from the pool of all unconditional forecasts.

%macro scEstimateAndForecast(tblSample,alpha,lead,nmc,tblUcf,tblUcfSim);
   * tblSample: input table name for in-sample data;
   * alpha: size of the credible interval;
   * lead: future horizons;
   * nmc: number of Monte Carlo iterations;
   * tblUcf: output table name of unconditional point and interval
             forecasts;
   * tblUcfSim: output table name of simulated unconditional forecasts;
   proc varmax data=&tblSample.;
      model y1 - y3 / p=2 prior noprint;
      condfore alpha=&alpha. lead=&lead. out=&tblUcf. outsim=&tblUcfSim.
         parm=sampling nbi=1000 nmc=&nmc.;
   run;
%mend;

The scenarios for four types of soft conditions are constructed from the following macro. To set up the correct bounds, both the true DGP (data-generating process) and unconditional forecasts are used. In the real world, the true DGP is not available, and those bound values reflect the scenarios of interest.

%macro scConstructScenarios(T,lead,tblDGP,tblUcf);
   * T: in-sample sample size;
   * lead: future horizons;
   * tblDGP: input table name for full-sample data;
   * tblUcf: input table name of unconditional point and interval
             forecasts;
   * four scenarios are implicitly output:
        scenarios i, i=1 to 4: future y3 is known for
           lb_j<=y3_j<=ub_j, j=1 to i, where lb_j and ub_j are lower and
           upper bounds whose values are saved in the corresponding macro
           variables, and y3_j is the j-step-ahead furture value of y3;
   data _NULL_;
      set &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+&lead.) keep=Y3);
      set &tblUcf.(keep=step Y3_MEDIAN Y3_LB Y3_UB);
      array q[&lead.] q1 - q&lead.;
      array lb[&lead.] lb1 - lb&lead.;
      array ub[&lead.] ub1 - ub&lead.;
      retain q lb ub;
      if(Y3<=Y3_LB) then do;
         q[step] = 1; ub[step] = Y3_LB;
      end;
      if (Y3>Y3_LB and Y3<=Y3_MEDIAN) then do;
         q[step] = 2; lb[step] = Y3_LB; ub[step] = Y3_MEDIAN;
      end;
      if (Y3>Y3_MEDIAN and Y3<=Y3_UB) then do;
         q[step] = 3; lb[step] = Y3_MEDIAN; ub[step] =Y3_UB;
      end;
      if (Y3>Y3_UB) then do;
         q[step] = 4; lb[step] = Y3_UB;
      end;
      if(_N_=&lead.) then do;
         %do i = 1 %to &lead.;
            call symputx("lb&i.",lb&i.,'G');
            call symputx("ub&i.",ub&i.,'G');
         %end;
      end;
   run;
%mend;

The simulated forecasts that satisfy each type of soft condition in each scenario are selected in the following macro:

%macro scClassifySimulatedForecasts(lead,tblUcfSim,tblSCSim);
   * lead: future horizons;
   * tblUcfSim: output table name of simulated unconditional forecasts;
   * tblSCSim: output table name of simulated conditional forecasts
               under soft conditioins specified in the scenarios;
   data &tblSCSim.;
      set &tblUcfSim.;
      array lb[&lead.] lb1 - lb&lead.;
      array ub[&lead.] ub1 - ub&lead.;
      array y3f[&lead.] y3_1 - y3_&lead.;
      %do j = 1 %to &lead.;
         lb[&j.]=&&lb&j.; ub[&j.]=&&ub&j.;
      %end;
      do myScenario=1 to 4;
         outputCond = 1;
         do i = 1 to myScenario;
            if(outputCond=1) then do;
               if(lb[i]=.) then do;
                  if(y3f[i]<=ub[i]) then outputCond=1;
                  else outputCond = 0;
               end;
               else do;
                  if(ub[i]=.) then do;
                     if(y3f[i]>lb[i]) then outputCond=1;
                     else outputCond = 0;
                  end;
                  else do;
                     if(y3f[i]>lb[i] and y3f[i]<=ub[i]) then outputCond=1;
                     else outputCond = 0;
                  end;
               end;
            end;
         end;
         if(outputCond=1) then output;
      end;
   run;
   proc sort data=&tblSCSim.; by myscenario; run;
%mend;

The point and interval forecasts for each scenario of soft conditions are generated from the following macro:

%macro scGetForecastStats(alpha,lead,tblSCSim,tblSCForecasts);
   * alpha: size of the credible interval;
   * lead: future horizons;
   * tblSCSim: input table name of simulated conditional forecasts
               under soft conditioins specified in the scenarios;
   * tblSCForecasts: output table name of conditional point and interval
               forecasts under soft conditioins specified in the scenarios;
   data _NULL_;
      lbPctl = &alpha./2*100;
      ubPctl = 100-lbPctl;
      call symputx("lbPctl",lbPctl,'G');
      call symputx("ubPctl",ubPctl,'G');
   run;
   proc univariate data=&tblSCSim. noprint;
      var y1_1 - y1_&lead. y2_1 - y2_&lead.;
      output out=oucfx pctlpts=&lbPctl. &ubPctl. 50
         pctlpre=%do j=1 %to &lead.; y1_&j. %end;
                 %do j=1 %to &lead.; y2_&j. %end;
         pctlname=_lb _ub _median;
      by myscenario;
   run;
   data &tblSCForecasts.;
      set oucfx;
      array y1f[&lead.]  %do j=1 %to &lead.; Y1_&j._median %end; ;
      array y1lb[&lead.] %do j=1 %to &lead.; Y1_&j._lb     %end; ;
      array y1ub[&lead.] %do j=1 %to &lead.; Y1_&j._ub     %end; ;
      array y2f[&lead.]  %do j=1 %to &lead.; Y2_&j._median %end; ;
      array y2lb[&lead.] %do j=1 %to &lead.; Y2_&j._lb     %end; ;
      array y2ub[&lead.] %do j=1 %to &lead.; Y2_&j._ub     %end; ;
      do i = 1 to &lead.;
         Y1_MEDIAN = y1f[i];
         Y1_LB = y1lb[i];
         Y1_UB = y1ub[i];
         Y2_MEDIAN = y2f[i];
         Y2_LB = y2lb[i];
         Y2_UB = y2ub[i];
         step = i;
         output;
      end;
      keep myscenario step y1_median y1_lb y1_ub y2_median y2_lb y2_ub;
   run;
%mend;

The following macro saves all types of forecasts for one simulated data set to one data set for evaluation:

%macro scSaveForecasts(dgpi,T,lead,tblDGP,tblUcf,tblSCForecasts,tblAll);
   * dgpi: index of DGP;
   * T: in-sample sample size;
   * lead: future horizons;
   * tblDGP: input table name for full-sample data;
   * tblUcf: input table name of unconditional point and interval
             forecasts;
   * tblSCForecasts: input table name of conditional point and interval
                     forecasts under soft conditioins specified in the scenarios;
   * tblAll: output table name of point and interval forecasts for all DGPs;
   data forecasts;
      set &tblDGP.(firstobs=%eval(&T.+1) obs=%eval(&T.+&lead.) keep=Y1 Y2);
      %do i = 1 %to 4;
         set &tblSCForecasts.( where=(myscenario_S&i.=&i.)
            rename=( Y1_MEDIAN=Y1_S&i. Y2_MEDIAN=Y2_S&i.
                     Y1_LB=Y1_LB_S&i. Y1_UB=Y1_UB_S&i.
                     Y2_LB=Y2_LB_S&i. Y2_UB=Y2_UB_S&i.
                     myscenario=myscenario_S&i.)
            keep=myscenario Y1_MEDIAN Y2_MEDIAN Y1_LB Y1_UB Y2_LB Y2_UB);
      %end;
      set &tblUcf.(
            rename=( Y1_MEDIAN=Y1_S5 Y2_MEDIAN=Y2_S5
                     Y1_LB=Y1_LB_S5 Y1_UB=Y1_UB_S5
                     Y2_LB=Y2_LB_S5 Y2_UB=Y2_UB_S5 )
            keep=Y1_MEDIAN Y2_MEDIAN Y1_LB Y1_UB Y2_LB Y2_UB);
      dgpIndex = &dgpi.;
      h = _N_;
      drop myscenario_S1 - myscenario_S4;
   run;

   proc append base=&tblAll. data=forecasts; run;
%mend;

The following macro incorporates all previous macros to test the forecasts for different scenarios (unconditional versus four types of soft conditions). All point and interval forecasts are saved in the data set that is specified in the tblAll argument. All evaluation results are saved in the data set that is specified in the tblEval argument.

%macro scTest(nSim,T,lead,alpha,nmc,nScenarios,qScenario0,scenarioBM,
   tblAll,tblEval);
   * nSim: number of DGPs;
   * T: in-sample sample size;
   * lead: future horizons;
   * alpha: size of the confidence interval or credible interval;
   * nmc: number of Monte Carlo iterations;
   * nScenarios: number of scenarios;
   * qScenario0: whether there is S0 for equation-based forecasts,
                 1 for yes and 0 for no;
   * scenarioBM: the index of the benchmark scenario;
   * tblAll: output table name of point and interval forecasts for all DGPs;
   * tblEval: output table name for evaluation results;
   %do iSim = 1 %to &nSim.;
      %cfSimulateData(&iSim.,&T.,&lead.,t1,t2);
      %scEstimateAndForecast(t2,&alpha.,&lead.,&nmc.,oucf,oucfsim);
      %scConstructScenarios(&T.,&lead.,t1,oucf);
      %scClassifySimulatedForecasts(&lead.,oucfsim,oucfsimx);
      %scGetForecastStats(&alpha.,&lead.,oucfsimx,oscf);
      %scSaveForecasts(&iSim.,&T.,&lead.,t1,oucf,oscf,&tblAll.);
   %end;
   %cfEvaluate(&tblAll.,&lead.,&nSim.,
               &nScenarios.,&qScenario0.,&scenarioBM.,
               &tblEval.);
%mend;

The following macro variables and macro set up and perform the test:

%let nSim = 1000;
%let T = 200;
%let lead = 4;
%let alpha = 0.50;
%let nmc = 100000;
%let nScenarios = 5;
%let qScenario0 = 0;
%let scenarioBM = 5;
%scTest(&nSim., &T.,&lead.,&alpha.,&nmc.,
        &nScenarios.,&qScenario0.,&scenarioBM.,
        scForecasts,scEval);

In order to show the result in a good style, the following template is created for the evaluation data set:

proc template;
   define table scEvalTemplate;
      column col3 col4 col5 col6 col7 col8;
      define header sc;
         text "Conditional Forecasts, Soft Conditions";
         start=col4; end=col7;
      end;
      define column col3;
         header="Horizon";
      end;
      define column col4;
         header="Scenario 1"; format=12.5;
      end;
      define column col5;
         header="Scenario 2"; format=12.5;
      end;
      define column col6;
         header="Scenario 3"; format=12.5;
      end;
      define column col7;
         header="Scenario 4"; format=12.5;
      end;
      define column col8;
         header="Unconditional"; format=12.5;
      end;
   end;
run;

The following macro calls print the sMAPEs for y1 and y2 in Output 42.5.9 and Output 42.5.10, respectively. An interesting fact is that as the horizon increases, the accuracy of forecasts for y1 in each scenario gets better (which is not common) and the accuracy of forecasts for y2 in each scenario gets worse (which is common). However, the forecasting methods can still be compared.

%cfPrint(scEvalTemplate, scEval(where=(col1=1 and col2=1)));
%cfPrint(scEvalTemplate, scEval(where=(col1=1 and col2=2)));

Output 42.5.9: The sMAPEs for y1

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.907330.899250.902730.899490.90144
20.887310.882710.882820.878620.88429
30.878910.876260.875050.868200.87613
40.870620.868640.867570.862060.86852


Output 42.5.10: The sMAPEs for y2

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
11.066271.069991.068611.066881.07902
21.144201.148131.146741.143761.16096
31.209601.211501.201061.193651.22223
41.260861.260501.250221.241811.27045


The following macro calls print the relative sMAPEs for y1 and y2 in Output 42.5.11 and Output 42.5.12, respectively. Most relative sMAPEs for conditional forecasts under soft conditions are less than 1, which means that those conditional forecasts have a better accuracy than the unconditional forecasts have. The forecasts in scenario 4, compared to other forecasts for each horizon, always have the smallest relative sMAPEs, which means that the conditional forecasts under soft conditions successfully take the advantage of the available future information.

%cfPrint(scEvalTemplate, scEval(where=(col1=2 and col2=1)));
%cfPrint(scEvalTemplate, scEval(where=(col1=2 and col2=2)));

Output 42.5.11: The Relative sMAPEs for y1

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
11.006540.997571.001440.997841.00000
21.003420.998210.998340.993591.00000
31.003171.000140.998770.990941.00000
41.002421.000140.998910.992571.00000


Output 42.5.12: The Relative sMAPEs for y2

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.988180.991630.990350.988751.00000
20.985560.988940.987750.985181.00000
30.989660.991220.982680.976621.00000
40.992450.992170.984080.977461.00000


The following macro calls print the sizes for y1 and y2 in Output 42.5.13 and Output 42.5.14, respectively. All sizes are around 0.5 (the nominal significance level), which means that all interval forecasts have the correct size.

%cfPrint(scEvalTemplate, scEval(where=(col1=3 and col2=1)));
%cfPrint(scEvalTemplate, scEval(where=(col1=3 and col2=2)));

Output 42.5.13: The Sizes for y1

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.506000.509000.510000.506000.49700
20.500000.506000.503000.510000.50500
30.502000.503000.490000.501000.50000
40.508000.507000.513000.510000.49900


Output 42.5.14: The Sizes for y2

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.489000.486000.488000.488000.49300
20.495000.462000.467000.459000.49300
30.508000.493000.495000.491000.50600
40.478000.461000.464000.459000.47200


The following macro calls print the relative interval lengths for y1 and y2 in Output 42.5.15 and Output 42.5.16, respectively. All conditional forecasts under soft conditions have a relative interval length of less than 1, which means that the conditional forecasts provide better interval forecasts than unconditional forecasts, given that all forecasts have the correct size. The smallest relative interval lengths for each horizon almost always lie in the columns of scenario 4, which indicates that more information results in better interval forecasts.

%cfPrint(scEvalTemplate, scEval(where=(col1=4 and col2=1)));
%cfPrint(scEvalTemplate, scEval(where=(col1=4 and col2=2)));

Output 42.5.15: The Relative Interval Lengths for y1

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.976680.963090.958050.958081.00000
20.999570.977880.966820.959401.00000
30.998290.997970.980400.965681.00000
40.996590.994790.993520.976361.00000


Output 42.5.16: The Relative Interval Lengths for y2

Conditional Forecasts and Scenario Analysis

HorizonConditional Forecasts, Soft ConditionsUnconditional
Scenario 1Scenario 2Scenario 3Scenario 4
10.987720.986160.986710.985401.00000
20.993560.978180.974090.973031.00000
30.994950.986840.972110.966401.00000
40.997750.993290.984590.971661.00000


In summary, you can make the following conclusions from the preceding results:

  • Compared to simulation-based unconditional forecasts, equation-based unconditional forecasts have similar accuracy for point forecasts but worse accuracy for interval forecasts, perhaps because the equation-based method does not consider the uncertainty of parameters.

  • Compared to simulation-based unconditional forecasts, simulation-based conditional forecasts under hard or soft conditions have better accuracy for both point and interval forecasts. As more future information becomes available, the conditional forecasts can become more accurate.

Last updated: June 19, 2025