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

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
Obsidian | Level 7

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
Obsidian | Level 7
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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