BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sasalex2024
Quartz | Level 8

Dear SAS Community,

I would like to ask for your advice on how to perform a formal test for constant variance (homoscedasticity) in the innovation series when using the proc arima procedure.

For example, the code below runs SARIMA (0,1,1)x(0,1,1)_12 model and generates a residual plot, which can visually help in identifying variance changes:

proc arima data=a
plots(only)=(residual(smooth));
identify var=Zt(1,12);
estimate p=(0)(0) q=(1)(12) method=ml noconstant;
run; 

However, I was wondering if it is possible to conduct a formal test to determine whether the residuals of a fitted model are homoscedastic.

I’ve heard about a series of tests developed by McLeod and his co-authors, but I’m not sure how to implement such (or any relevant) tests in SAS.

I would greatly appreciate your guidance on this topic.

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

This page contains all the info to interpret the output of ARCHTEST option in PROC AUTOREG!

SAS Help Center: Testing for Heteroscedasticity

Note that you can ask for different flavours of this ARCHTEST option.

  • model y = time / archtest ;
  • model y = time / archtest=(qlm) ;
  • model y = time / archtest=(lk,wl) ; 

 

I tested ARCHTEST option myself with seriesg (series-G).

Here's more info on Box and Jenkins Series-G (International Airline Passengers)

SAS Help Center: Seasonal Model for the Airline Series

 

/*-- Seasonal Model for the Airline Series --*/
data seriesg;
 set sashelp.air;
 xlog = log( air );
run;

proc arima data=seriesg;
   identify var=xlog(1,12);
   estimate q=(1)(12) noint method=ml;
   forecast id=date lead=0 interval=month printall out=b;
run;
QUIT;

data c;
 set b;
 where residual is not missing;
 Time + 1;
run;

/* Test for heteroscedastic residuals */
proc autoreg data=c;
   model residual = Time / archtest;
  *output out=r r=yresid;
run;
/* end of program */

Cheers,

Koen

View solution in original post

5 REPLIES 5
sbxkoenk
SAS Super FREQ

BR, Koen

sasalex2024
Quartz | Level 8

Thank you very much   for the quick and detailed reply. Based on this, I've replied to my own question with a code, do you think it is acceptable as a solution? Thank you very much again.

sasalex2024
Quartz | Level 8
proc arima data=a
identify var=Zt(1,12);
estimate p=(0)(0) q=(1)(12) method=ml noconstant;
forecast lead=0 interval=month id=Date out=results;
run; 

data residuals_only;
set results;
if not missing(residual) then do; 
        Time + 1; 
        output; 
    end;
keep residual Time;
run;

/* Test for heteroscedastic residuals */
proc autoreg data=residuals_only;
   model residual = Time / archtest;
   output out=r r=yresid;
run;
sbxkoenk
SAS Super FREQ

>> ... , I've replied to my own question with a code, do you think it is acceptable as a solution? Thank you very much again.

 

It's oké.

But you need to terminate PROC ARIMA with a QUIT; statement. PROC ARIMA is an interactive procedure.
Because the PROC ARIMA is followed by a data step (in your code) , there's an implicit QUIT ... but still I prefer to put it.

If you only submit the PROC ARIMA part , you will notice the last statement (the forecast statement) is not executed. The output dataset with residuals is not created.

 

Interactive procedures in SAS - The DO Loop

 

Running interactive procedures in SAS Studio and SAS University Edition - The DO Loop

 

Do you write unnecessary SAS statements? - The DO Loop

 

Ciao,
Koen

sbxkoenk
SAS Super FREQ

This page contains all the info to interpret the output of ARCHTEST option in PROC AUTOREG!

SAS Help Center: Testing for Heteroscedasticity

Note that you can ask for different flavours of this ARCHTEST option.

  • model y = time / archtest ;
  • model y = time / archtest=(qlm) ;
  • model y = time / archtest=(lk,wl) ; 

 

I tested ARCHTEST option myself with seriesg (series-G).

Here's more info on Box and Jenkins Series-G (International Airline Passengers)

SAS Help Center: Seasonal Model for the Airline Series

 

/*-- Seasonal Model for the Airline Series --*/
data seriesg;
 set sashelp.air;
 xlog = log( air );
run;

proc arima data=seriesg;
   identify var=xlog(1,12);
   estimate q=(1)(12) noint method=ml;
   forecast id=date lead=0 interval=month printall out=b;
run;
QUIT;

data c;
 set b;
 where residual is not missing;
 Time + 1;
run;

/* Test for heteroscedastic residuals */
proc autoreg data=c;
   model residual = Time / archtest;
  *output out=r r=yresid;
run;
/* end of program */

Cheers,

Koen

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 5 replies
  • 2319 views
  • 3 likes
  • 2 in conversation