BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mark-adamson
Fluorite | Level 6

I am using proc arima in SAS 9.4 to produce a forecast using a previously calibrated model, but it is throwing an error as if it is trying to calibrate the model itself :

ERROR: There is not enough data to fit the model

sample data:

data inputs;
input x var1 var2 var3 var4 var5;
datalines;
  20    5   2   4   5   4
  25    12  56  13  44  4
  20    5   2   4   5   4
  25    12  56  13  44  4
  20    5   2   4   5   4
  25    12  56  13  44  4
   .    2   5   6   5   4
;

failing version:

proc arima;
  identify 
    data = inputs 
    var = x
    crossCorr = ( var1 var2 var3 var4 var5 ) 
    noPrint;

  estimate 
    p = 1 input = ( var1 var2 var3 var4 var5 )
    ar = 0.9
    initVal = ( 0.1$var1 0.2$var2 0.3$var3 0.4$var4 0.4$var5 ) 
    noint 
    noEst /* Using noEst so should not need to do any estimation and short data-set should not be a problem */
    method=ml 
    noprint
;

  forecast lead=1 out=outputs noOutAll noprint;
quit;

If I remove the final variable from the model, it works fine:

proc arima;
  identify 
    data = inputs 
    var = x
    crossCorr = ( var1 var2 var3 var4 ) 
    noPrint;

  estimate 
    p = 1 input = ( var1 var2 var3 var4 )
    ar = 0.9
    initVal = ( 0.1$var1 0.2$var2 0.3$var3 0.4$var4 ) 
    noint 
    noEst /* Using noEst so should not need to do any estimation and short data-set should not be a problem */
    method=ml 
    noprint 
;

  forecast lead=1 out=outputs noOutAll noprint;
quit;

I can also get it to 'work' by adding one more value to the data. However, this shouldn't be necessary when the model is already calibrated (using much more data).

I've checked the SAS documentation to see if there are any flags to prevent the unnecessary check that causes this error but none of them helped.

 

Cross-posted on stack-overflow

1 ACCEPTED SOLUTION

Accepted Solutions
rselukar
SAS Employee

We cannot let you go back to R without some fight (just kidding)!  You can use PROC SSM (as shown below) to get what you want.  This procedure is for linear state space modeling (ARIMA models are state space models).  See the doc at http://support.sas.com/documentation/cdl/en/etsug/68148/HTML/default/viewer.htm#etsug_ssm_syntax.htm

 

In the code illustration below I have added an MA(1) term to the model since you said your models might have MA terms.  Moreover, you can also specify the error variance from your calibrated model.

 

data inputs;

input x var1 var2 var3 var4 var5;

datalines;

20 5 2 4 5 4

25 12 56 13 44 4

20 5 2 4 5 4

25 12 56 13 44 4

20 5 2 4 5 4

25 12 56 13 44 4

. 2 5 6 5 4

;

/* Without known AR error variance*/

proc ssm data=inputs;

trend ar(arma(p=1 q=1)) ar=0.9 ma=0.3;

cin = 0.1*var1 + 0.2*var2 + 0.3*var3 + 0.4*var4 + 0.4*var5;

state tf(1) sinput=(cin);

comp tfTerm = tf[1];

model x = tfTerm ar / print=smooth;

output out=for pdv;

run;

/* With known AR error variance=10 say*/

proc ssm data=inputs;

trend ar(arma(p=1 q=1)) ar=0.9 ma=0.3 variance=10;

cin = 0.1*var1 + 0.2*var2 + 0.3*var3 + 0.4*var4 + 0.4*var5;

state tf(1) sinput=(cin);

comp tfTerm = tf[1];

model x = tfTerm ar / print=smooth;

output out=for pdv;

run;

View solution in original post

5 REPLIES 5
rselukar
SAS Employee

ARIMA does exit if the number of non-missing observations are less than or equal to the number of parameters in the model whether parameters are known or not.  This behavior is known.  This use case scenario is somewhat uncommon and ARIMA does not handle it.  As you have said, you could add some rows (possibly artificial data) at the beginning to take care of this scenario.  By the way, for these types of scenarios Forecast Server offers specialized scoring functionality for ARIMA models that could be of interest to you.

 

mark-adamson
Fluorite | Level 6

Thank you for the quick response and clear answer. That is unfortunate and it means we will go back to R for this model which handles it without any problems. Adding in artificial data will change the result in our real model since we are using MA terms, so that isn't a viable workaround for us.

rselukar
SAS Employee

We cannot let you go back to R without some fight (just kidding)!  You can use PROC SSM (as shown below) to get what you want.  This procedure is for linear state space modeling (ARIMA models are state space models).  See the doc at http://support.sas.com/documentation/cdl/en/etsug/68148/HTML/default/viewer.htm#etsug_ssm_syntax.htm

 

In the code illustration below I have added an MA(1) term to the model since you said your models might have MA terms.  Moreover, you can also specify the error variance from your calibrated model.

 

data inputs;

input x var1 var2 var3 var4 var5;

datalines;

20 5 2 4 5 4

25 12 56 13 44 4

20 5 2 4 5 4

25 12 56 13 44 4

20 5 2 4 5 4

25 12 56 13 44 4

. 2 5 6 5 4

;

/* Without known AR error variance*/

proc ssm data=inputs;

trend ar(arma(p=1 q=1)) ar=0.9 ma=0.3;

cin = 0.1*var1 + 0.2*var2 + 0.3*var3 + 0.4*var4 + 0.4*var5;

state tf(1) sinput=(cin);

comp tfTerm = tf[1];

model x = tfTerm ar / print=smooth;

output out=for pdv;

run;

/* With known AR error variance=10 say*/

proc ssm data=inputs;

trend ar(arma(p=1 q=1)) ar=0.9 ma=0.3 variance=10;

cin = 0.1*var1 + 0.2*var2 + 0.3*var3 + 0.4*var4 + 0.4*var5;

state tf(1) sinput=(cin);

comp tfTerm = tf[1];

model x = tfTerm ar / print=smooth;

output out=for pdv;

run;

mark-adamson
Fluorite | Level 6

Thanks for that, proc ssm looks very promising and powerful. I may have a go at converting what I have done with proc arima to use it. It looks like it has nicer syntax than proc arima for doing differencing and including seasonality too, both relevant to us. 

 

SAS gets +5 points in the SAS vs. R showdown...

rselukar
SAS Employee

The syntax of PROC SSM is more complex than ARIMA and you might need some time to get used to it.  If you need syntax help for converting any ARIMA spec (including transfer function type terms) contact me separately and I will help you. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 2641 views
  • 11 likes
  • 2 in conversation