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

Dear SAS community, I would like to:
1) run ARMA (1,2) model for "change in sale", with control variables price and income:
change in sale = f(price, income, lag1 of change in sale, lag1 error, lag2 error, error term)

2) plot the residuals.

3) save the output, including original data, parameters and residuals.

It is something like the following, could you kindly help to correct? Thanks in advance!

 

proc arima data=have;
identify var=sales(1) crosscorr=(price income) noprint;
estimate input=(price income) plot;
run;
estimate p=1 q=2 input=(price income) outest=arma_sale;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
dw_sas
SAS Employee

Hi @JacAder

 

PROC ARIMA can be used to fit a regression model with ARMA errors, as shown in the link below:

https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_arima_gettingstarted25.htm&docse... 

 

However, if you want to fit the model:

 

"change in sale = f(price, income, lag1 of change in sale, lag1 error, lag2 error, error term)"

 

then you can use other SAS procedures, such as PROC UCM or PROC VARMAX.  For your desired model, PROC VARMAX provides the most straightforward approach.  Your model, residual plot, and saved output can be obtained with the following code.  Note:  Although PROC VARMAX supports an OUTEST= data set, the code below illustrates how to output the ParameterEstimates table via an ODS OUTPUT statement.  It saves the parameter estimates table in a different format than the OUTEST= data set.

 

proc varmax data=have plots=(model residual); 
  ods output ParameterEstimates=arma_est;
  id date interval=month;
  model sales = price income / p=1 q=2 dify(1);* difx(1);
  output out=out lead=0; 
run;

proc print data=arma_est;
run;

data all_varmax;
  merge have out;
  by date;
run;

proc print data=all_varmax;
  var date sales price income for1 res1;
run;

When the response variable is differenced, it is common to apply the same order of differencing to the input variables as well.  I included the DIFX option in the MODEL statement to illustrate how to difference the input variables, but commented it out, since that was not used in your model description.

 

For more details on the mathematical models fit by the ARIMA and VARMAX procedures, please see the following links:

ARIMA:  https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_arima_gettingstarted13.htm&docse... 

 

VARMAX:  https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_varmax_details02.htm&docsetVersi...

 

I hope this helps!

DW

View solution in original post

2 REPLIES 2
dw_sas
SAS Employee

Hi @JacAder

 

PROC ARIMA can be used to fit a regression model with ARMA errors, as shown in the link below:

https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_arima_gettingstarted25.htm&docse... 

 

However, if you want to fit the model:

 

"change in sale = f(price, income, lag1 of change in sale, lag1 error, lag2 error, error term)"

 

then you can use other SAS procedures, such as PROC UCM or PROC VARMAX.  For your desired model, PROC VARMAX provides the most straightforward approach.  Your model, residual plot, and saved output can be obtained with the following code.  Note:  Although PROC VARMAX supports an OUTEST= data set, the code below illustrates how to output the ParameterEstimates table via an ODS OUTPUT statement.  It saves the parameter estimates table in a different format than the OUTEST= data set.

 

proc varmax data=have plots=(model residual); 
  ods output ParameterEstimates=arma_est;
  id date interval=month;
  model sales = price income / p=1 q=2 dify(1);* difx(1);
  output out=out lead=0; 
run;

proc print data=arma_est;
run;

data all_varmax;
  merge have out;
  by date;
run;

proc print data=all_varmax;
  var date sales price income for1 res1;
run;

When the response variable is differenced, it is common to apply the same order of differencing to the input variables as well.  I included the DIFX option in the MODEL statement to illustrate how to difference the input variables, but commented it out, since that was not used in your model description.

 

For more details on the mathematical models fit by the ARIMA and VARMAX procedures, please see the following links:

ARIMA:  https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_arima_gettingstarted13.htm&docse... 

 

VARMAX:  https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_varmax_details02.htm&docsetVersi...

 

I hope this helps!

DW

JacAder
Obsidian | Level 7

That's very helpful, thanks a lot!

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
  • 2 replies
  • 702 views
  • 1 like
  • 2 in conversation