BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi,

I have an estimated ARIMA model, and based on that I have the forecast for the next x periods.

I need the prediction and prediction (forecast) intervals for the following:

0.5*forecast_lead_2+forecast_lead_7

In the below example the prediction (forecast) is:

0.5*118440.4517 + 119798.8033

How can I calculate intervals?


proc arima data=sashelp.citimon;

      i var=CCIUAC(1);

      e p=6 q=1;

      f lead=12 out=forecast;

run;

quit;

In a general case I need prediction for the linear combination of forecasts with prediction intervals.

Thx

1 ACCEPTED SOLUTION

Accepted Solutions
gergely_batho
SAS Employee

I tried to use the Inpulse Respoonse Function of the model to get the mentioned forecast intervals:

Each random shock is independent, so I can add the variance (sigma**2) weighted by the IRF. Then take the square root.

This is also how the simple forecast intervals (Standard Errors) are calculated.

Now I only need to be careful with the linear combination. For example the effect of the random shock at lead(2)  - remember, we are calculating std error for lead(7) – is: 0.5*irf(0) + irf(5)

Anybody can see a theoretical error in this approach?

PROC VARMAX can be used, to get the IRF.

Here's a code:

proc varmax data=sashelp.citimon;

  model CCIUAC / dif(CCIUAC(1)) q=1 p=4 /*6*/ method=ml print=(impulse=(simple accum )) lagmax=6 ;

  output out=vforecast lead=12;

run;

data _null_;

  sigma=sqrt(586153.48852); /* number copied here from the output of VARMAX*/

  array irf[0:7] (1, 0.33369, 0.29371, 0.46347, 0.23512, 0.21355, 0.22610, 0.14592);/*Impulse Response - numbers copied here from the output of VARMAX*/

  array airf[0:7];/*Accumulated Impulse Response*/

  airf[0]=1; do i=1 to 7; airf=airf[i-1]+irf;end;/*calculating airf from irf*/

  /*Calculating StdErr for forecast lead 2*/

  do i=0 to 1;

  std_2+airf**2;

  end;

  std_2=sqrt(std_2)*sigma;

  /*Calculating StdErr for forecast lead 7*/

  do i=0 to 6;

  std_7+airf**2;

  end;

  std_7=sqrt(std_7)*sigma;

  /*Calculating StdErr for the linear combination*/

  /*It is similar to a convolution operator, but you sum the squares*/

  do i=0 to 6;

  if 0<=i<=4 then do;/**/

lincomb+airf**2;

  end;

  else do;/*5 and 6*/

lincomb+(airf+0.5*airf[i-5])**2;

  end;

  end;

  lincomb=sqrt(lincomb)*sigma;

  putlog sigma= std_2= std_7= lincomb=;

run;

Perhaps SAS/IML can do this with less coding.

Thx

View solution in original post

4 REPLIES 4
gergely_batho
SAS Employee

Thank you Udo,

The mentioned paper is about combining forecasts of different models. But I have only one model, and I want to forecast (calculate) the linear combination of forecasts of two different periods.

On the other hand the suggested paper contains a description about calculating forecast confidence intervals using the sample cross correlation. Maybe that idea could be useful in my situation.

I still think it should be possible (somehow) to derive the cross correlation between forecast_lead_2 and forecast_lead_7 simply by using the model parameter estimates.

Or maybe this (linear combination) forecast interval could be directly calculated using the forecast intervals of the original forecasts.

Thx

gergely_batho
SAS Employee

I tried to use the Inpulse Respoonse Function of the model to get the mentioned forecast intervals:

Each random shock is independent, so I can add the variance (sigma**2) weighted by the IRF. Then take the square root.

This is also how the simple forecast intervals (Standard Errors) are calculated.

Now I only need to be careful with the linear combination. For example the effect of the random shock at lead(2)  - remember, we are calculating std error for lead(7) – is: 0.5*irf(0) + irf(5)

Anybody can see a theoretical error in this approach?

PROC VARMAX can be used, to get the IRF.

Here's a code:

proc varmax data=sashelp.citimon;

  model CCIUAC / dif(CCIUAC(1)) q=1 p=4 /*6*/ method=ml print=(impulse=(simple accum )) lagmax=6 ;

  output out=vforecast lead=12;

run;

data _null_;

  sigma=sqrt(586153.48852); /* number copied here from the output of VARMAX*/

  array irf[0:7] (1, 0.33369, 0.29371, 0.46347, 0.23512, 0.21355, 0.22610, 0.14592);/*Impulse Response - numbers copied here from the output of VARMAX*/

  array airf[0:7];/*Accumulated Impulse Response*/

  airf[0]=1; do i=1 to 7; airf=airf[i-1]+irf;end;/*calculating airf from irf*/

  /*Calculating StdErr for forecast lead 2*/

  do i=0 to 1;

  std_2+airf**2;

  end;

  std_2=sqrt(std_2)*sigma;

  /*Calculating StdErr for forecast lead 7*/

  do i=0 to 6;

  std_7+airf**2;

  end;

  std_7=sqrt(std_7)*sigma;

  /*Calculating StdErr for the linear combination*/

  /*It is similar to a convolution operator, but you sum the squares*/

  do i=0 to 6;

  if 0<=i<=4 then do;/**/

lincomb+airf**2;

  end;

  else do;/*5 and 6*/

lincomb+(airf+0.5*airf[i-5])**2;

  end;

  end;

  lincomb=sqrt(lincomb)*sigma;

  putlog sigma= std_2= std_7= lincomb=;

run;

Perhaps SAS/IML can do this with less coding.

Thx

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2072 views
  • 3 likes
  • 3 in conversation