Dear SAS Community,
Suppose I have standard PROC ARIMA commands like this:
proc arima data=a;
identify var=Yt crosscorr=(X1t X2t) noprint;
estimate q=1 input=( (1) X1t (1) X2t ) method=ml;
run;
The command displays a QQ plot of standardized residuals. However, if I want to access the values of those residuals, could you please guide me on how to do it?
I have tried using the outmodel etc, but I couldn't find a way to extract the residuals.
Thank you!
This is a Regression with ARMA Errors
I combine input series with an ARMA model for the error.
The following statements regress SALE
on DISCOUNT
and PRICE
but with the error term of the regression model (called the noise series in ARIMA modeling terminology) assumed to be an ARMA(1,1) process:
ods output ResidualNormalityPanel=work.abc;
proc arima data=sashelp.pricedata;
where region=1 AND line=1 and product=1;
identify var=sale crosscorr=(price discount);
estimate p=1 q=1 input=(price discount);
run;
QUIT;
It works !
Koen
The below code provides you with the (X,Y)-coordinates of the markers in the QQ-plot (see data set named "work.abc"), but the data are sorted. I don't know how you can find out which observation belongs to which time stamp in your time series.
title1 'Simulated IMA(1,1) Series';
data a;
u1 = 0.9; a1 = 0;
do i = -50 to 100;
a = rannor( 32565 );
u = u1 + a - .8 * a1;
if i > 0 then output;
a1 = a;
u1 = u;
end;
run;
*ods trace on; ods trace off;
ODS output ResidualNormalityPanel=work.abc;
/*-- Simulated IMA Model --*/
proc arima data=a;
identify var=u;
run;
identify var=u(1);
run;
estimate q=1 ;
run;
quit;
/* end of program */
Ciao, Koen
Dear Koen,
Thank you very much for your response. Your code works perfectly for the example model you provided. However, I have been unable to adapt it to my specific case, which involves extracting residuals from a model with inputs and ARMA errors. I tried including the lines:
*ods trace on; ods trace off;
ODS output ResidualNormalityPanel=work.abc;
before my PROC ARIMA code and ending with a quit; after the last run;. Unfortunately, this did not produce the dataset work.abc as expected. Would you be able to clarify if additional modifications are needed to make this approach work for models with inputs and ARMA errors? Thank you once again for your time and assistance!
@sasalex2024 wrote:
Dear Koen,
Thank you very much for your response. Your code works perfectly for the example model you provided. However, I have been unable to adapt it to my specific case, which involves extracting residuals from a model with inputs and ARMA errors. I tried including the lines:
*ods trace on; ods trace off; ODS output ResidualNormalityPanel=work.abc;
before my PROC ARIMA code and ending with a quit; after the last run;. Unfortunately, this did not produce the dataset work.abc as expected. Would you be able to clarify if additional modifications are needed to make this approach work for models with inputs and ARMA errors? Thank you once again for your time and assistance!
Run the trace on/off around your model code and show us the LOG. The log will include a bunch of bits with Names of the ODS objects created, include all of that along with the code and other messages the procedure generates. It may be that your install created a different ODS object than the ResidualNormalityPanel, or the spelling changed, from @sbxkoenk's install.
ODS TRACE ON; proc arima data=a; identify var=Yt crosscorr=(X1t X2t) noprint; estimate q=1 input=( (1) X1t (1) X2t ) method=ml; run; quit; ODS TRACE OFF;
Hi, thank you. This is the log:
ODS TRACE ON;
proc arima data=series_31;
identify var=Yt(1) crosscorr=(X1t(1) X2t(1) X3t(1)) noprint;
estimate q=1 input=( (1) X1t (1) X2t (1) X3t) method=ml;
run;
quit;
ODS TRACE OFF;
This part of your log:
Output Added: ------------- Name: ResidualNormalityPanel Label: Residual Normality Panel Template: ets.arima.Graphics.NormalityPanel Path: Arima.Estimate.ResidualNormalityPanel -------------
Looks like the ods object you want is the same as @sbxkoenk's code used.
Perhaps you can show the Log where you have the ODS OUTPUT statement with your model.
proc arima data=series_31; identify var=Yt(1) crosscorr=(X1t(1) X2t(1) X3t(1)) noprint; estimate q=1 input=( (1) X1t (1) X2t (1) X3t) method=ml; ODS OUTPUT ResidualNormalityPanel= work.yourdatasetname ; run; quit;
I don't have access to Proc Arima so can't run the code. There might be that with procedures supporting run group processing like Proc Arima that the location of the ODS OUTPUT has to be within the run group.
Thank you so much, I have run your code and it works too! It produces the same values as in the method given by Koen. Again, thank you very much.
This is a Regression with ARMA Errors
I combine input series with an ARMA model for the error.
The following statements regress SALE
on DISCOUNT
and PRICE
but with the error term of the regression model (called the noise series in ARIMA modeling terminology) assumed to be an ARMA(1,1) process:
ods output ResidualNormalityPanel=work.abc;
proc arima data=sashelp.pricedata;
where region=1 AND line=1 and product=1;
identify var=sale crosscorr=(price discount);
estimate p=1 q=1 input=(price discount);
run;
QUIT;
It works !
Koen
Thank you very much for your help. I ran the following code based on yours (shown below this message), and although the log shows an error: "ERROR: Variable region is not on file WORK.SERIES_31," it still produces the abc table in the Work directory.
I apologize for troubling you again, but there is a column in that table (the 10th column, I believe) named "residual." I assume these are the residuals from the model, correct? And they are sorted I suppose. If so, could you please tell me how I can obtain these residuals in their original, "unsorted" order? I also need to plot them over time.
Thank you again!
----
proc arima data=series_31;
where region=1 AND line=1 and product=1;
identify var=Yt(1) crosscorr=(X1t(1) X2t(1) X3t(1)) noprint;
estimate q=1 input=( (1) X1t (1) X2t (1) X3t) method=ml;
run;
quit;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.