We are implementing a VARX (Vector Autoregression with Exogenous variables) model using PROC VARMAX in SAS to forecast Loan Loss Provisions (LLP) based on macro financial variables. A critical requirement is that we can give an explicit model equation that allows for manual implementation outside of SAS. I.e., that the estimated coefficients can be used in external environments to generate forecasts by simply plugging in predictor values. As I am still learning this model, can someone with experience in this model tell me if it is possible to get such an explicit model equation from SAS using proc varmax (or otherwise)? Thank you!
VARX(p,s) model equation is discussed here in the PROC VARMAX documentation:
SAS Help Center: VAR and VARX Modeling
For a simple example of VARX(1,0) model with two dependent variables y1 and y2, one exogenous variable x, the model equations for y1 and y2 can be written like below:
y1_t = CONST1 + XL0_1_1*x_t +AR1_1_1*y1_t-1 + AR1_1_2*y2_t-1 + epsilon1_t
y2_t = CONST2 + XL0_2_1*x_t +AR1_2_1*y1_t-1 + AR1_2_2*y2_t-1 + epsilon2_t;
I hope this helps.
Thank you! What I am still not clear on is if this will be an equation that allows for manual implementation outside of SAS. I.e., that the estimated coefficients can be used in external environments to generate forecasts by simply plugging in predictor values. I am not clear from your answer if it is a yes to this question. Thank you.
In the MODEL statement of your PROC VARMAX, you need to include these options (after a forward slash):
print=(dynamic) printform=univariate;
The best portion of the printed output to look at in order to write down the equation(s) is the final table in the printed output. The ODS table name for this table (found by including an ODS TRACE ON / LISTING; statement with your PROC VARMAX step) is the DynamicParameterEstimates table. In the printed output, this table is labeled, "Dynamic Model Parameter Estimates".
This table provides the equation, the parameter estimate and the variable associated with that parameter estimate. Using this information, you can write down the model equation.
The prediction equations allow you to hand-calculate the predicted values (or have it done by Excel / Python / ...).
But ... as I write this, I do have my doubts. You’ll find various questions (topics) in these communities about ARIMAX models created using PROC ARIMA. In every of these topic-threads, the answer is that it’s incredibly complicated (if not impossible) to transfer prediction equations to Excel (for example). I suspect it won’t be any different for Multivariate ARIMA. You can, of course, give it a go.
Just do it in SAS (as a benchmark) and compare with doing it outside SAS.
In SAS ... if you want to score a completely new data set using parameters estimated in PROC VARMAX previously, then the easiest way to do this is to use a second PROC VARMAX step on the score data set with a RESTRICT statement to restrict *all* the parameter estimates to the previously estimated values.
BR, Koen
great, thank you!
In these equations in the VARX(1,0) model,
y1_t = CONST1 + XL0_1_1*x_t +AR1_1_1*y1_t-1 + AR1_1_2*y2_t-1 + epsilon1_t
y2_t = CONST2 + XL0_2_1*x_t +AR1_2_1*y1_t-1 + AR1_2_2*y2_t-1 + epsilon2_t;
current period y1_t and y2_t are expressed in terms of current period x_t, lagged period y1_t-1 and y2_t-1, they certainly allow you to compute forecast manually on y1_t and y2_t by plugging in x_t, y1_t-1, y2_t-1, as well as all the parameters in the equations. When actual values of y1_t-1 and y2_t-1 are available, you plug in the actual lagged y1_t-1 and y2_t-1 values. For future periods when no actual y1_t-1 and y2_t-1 are available any more, you substitute in the previously forecasted values for y1_t-1 and y2_t-1. Following is an example using data step computations to obtain forecast on y1 and y2 using the above equations for VARX(1,0) example. The computed forecast match those produced in PROC VARMAX output.
data a ;
do i = 1 to 100;
x = normal(1);
y1 = 2 + 3*x + rannor(235);
y2 = 3 + 2*x + rannor(21);
if i >90 then do ;
y1 = . ;
y2 = . ;
end;
output;
end;
run;
proc print data = a; run;
ods output parameterestimates = parm;
proc varmax data = a ;
model y1 y2 = x /p = 1 ;
output out = outs lead = 10 ;
run;
proc print data =parm; run;
proc transpose data = parm(keep = Estimate) out = parms(rename=(COL1=CONST1 COL2 =XL0_1_1 COL3 = AR1_1_1 COL4 =AR1_1_2 COL5 = CONST2 COL6=XL0_2_1 COL7=AR1_2_1 COL8=AR1_2_2));
run;
proc print data = parms; run;
data compte;
merge a outs; /* merge input and output data sets to get X values */
if _n_ = 1 then set parms; /* merge parameter estimates into data set */
t + 1;
lagy1 = lag(y1);
lagy2 = lag(y2);
lagfy1 = lag(for1);
lagfy2 = lag(for2);
if t <= 91 then forecast1 = CONST1 + XL0_1_1*x +AR1_1_1*lagy1 + AR1_1_2*lagy2;
if t > 91 then forecast1 = CONST1 + XL0_1_1*x +AR1_1_1*lagfy1 + AR1_1_2*lagfy2;
if t <= 91 then forecast2 = CONST2 + XL0_2_1*x +AR1_2_1*lagy1 + AR1_2_2*lagy2;
if t > 91 then forecast2 = CONST2 + XL0_2_1*x +AR1_2_1*lagfy1 + AR1_2_2*lagfy2;
diff1 = for1 - forecast1 ;
diff2 = for2 - forecast2 ;
run;
proc print data = compte;
var y1 y2 x for1 for2 forecast1 forecast2 diff1 diff2;
run;
I hope this helps.
great, thank you very much!
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →