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

Hi,

 

is there any way to restrich forcast to non negative value while using proc ARIMA. The code I am using is somthing like:

proc arima data=ECC_PROG.input_&model_id._FC;
        identify var=;
        crosscorr=;                
        estimate input=           maxiter=500
        outstat=work.stat_output;
        ods output ParameterEstimates=work.est_output;            
        forecast id=Monthfirstdate interval=current_month lead=20 out=work.fc_output;
    run;

 

The forcast series is:

 

2501.3670464
2108.8958506
2891.8512364
3296.7321201
2152.0694575
2268.121497
1762.4315729
725.869754
1352.3058047
1116.6313661
1682.9098849
1352.5916422
1817.0154846
942.74009745
1809.1170823
1724.7927787
2132.5585948
1509.8093098
629.94039571
524.47316682
483.21510113
784.94561717
1678.526544
3958.0868899
2623.3232306
3431.4607677
2358.1385337
2552.8319758
2970.995978
1573.3429921
875.34663397     (This is the first future forcast)
231.9825378
-656.1836936
-1190.827972
-939.7523543
-969.8491769
-794.5118323
-1534.474293
-1374.10823
-1097.835167
-961.7230223
-767.186427
-1417.2471
-2046.895848
-2983.043558
-3513.153141
-3275.711532

 

 The red marked forcast values should be non negative. As you see in the series after only two non negative futur forcasts, the series futur forcast becomes negative. Since I know I am forcasting the "expected number of persons who may change their status in futur ", it can not be negative. The least value of forcast could be zero. So I am looking for some way of restricting the forcast to non negative.

 

Do anybody has an Idea ?

 

thanks in advance for your time

Ehsan

1 ACCEPTED SOLUTION

Accepted Solutions
udo_sas
SAS Employee

Hello -

In my opinion you will need to deal with non-negativity requirements of your forecasts in a post processing step. The statistical model will provide you with an unconstrained forecast, based on the patterns at hand, which can be negative of course.

If, like in your case, you have additional requirements about the decisions at hand, like: forecasts cannot be negative (example: sales forecasting), forecasts need to be integer (example: number of call center agents), forecasts are impacted by supply options (example: inventory control, where products come in batches), etc. you will need to deal with them in a post process.

Some post-processing can be simple, like setting forecasts to 0, others can be more elaborate: overrides in a hierarchical setup with rules about what can be changed, which boil down to an optimization problem. Sometimes this is referred to as a constrained forecast.

Thanks,

Udo

 

PS: having said all of this you may want to make sure that your model is appropriate. I looked at your data briefly, maybe an ESM approach (using a damped trend model or a seasonal model for example) will do a better job - just a Friday morning thought.

Example:

data test;

input value;

datalines;

2501.3670464

2108.8958506

2891.8512364

3296.7321201

2152.0694575

2268.121497

1762.4315729

725.869754

1352.3058047

1116.6313661

1682.9098849

1352.5916422

1817.0154846

942.74009745

1809.1170823

1724.7927787

2132.5585948

1509.8093098

629.94039571

524.47316682

483.21510113

784.94561717

1678.526544

3958.0868899

2623.3232306

3431.4607677

2358.1385337

2552.8319758

2970.995978

1573.3429921

;

run;

proc esm data=test plot=(forecasts);

forecast value / model=damptrend;

run;

 

ForecastsPlot.png

 

*assuming seasonality of 12;

proc esm data=test plot=(forecasts) seasonality=12;

forecast value / model=seasonal;

run;

ForecastsPlot2.png

View solution in original post

4 REPLIES 4
udo_sas
SAS Employee

Hello -

In my opinion you will need to deal with non-negativity requirements of your forecasts in a post processing step. The statistical model will provide you with an unconstrained forecast, based on the patterns at hand, which can be negative of course.

If, like in your case, you have additional requirements about the decisions at hand, like: forecasts cannot be negative (example: sales forecasting), forecasts need to be integer (example: number of call center agents), forecasts are impacted by supply options (example: inventory control, where products come in batches), etc. you will need to deal with them in a post process.

Some post-processing can be simple, like setting forecasts to 0, others can be more elaborate: overrides in a hierarchical setup with rules about what can be changed, which boil down to an optimization problem. Sometimes this is referred to as a constrained forecast.

Thanks,

Udo

 

PS: having said all of this you may want to make sure that your model is appropriate. I looked at your data briefly, maybe an ESM approach (using a damped trend model or a seasonal model for example) will do a better job - just a Friday morning thought.

Example:

data test;

input value;

datalines;

2501.3670464

2108.8958506

2891.8512364

3296.7321201

2152.0694575

2268.121497

1762.4315729

725.869754

1352.3058047

1116.6313661

1682.9098849

1352.5916422

1817.0154846

942.74009745

1809.1170823

1724.7927787

2132.5585948

1509.8093098

629.94039571

524.47316682

483.21510113

784.94561717

1678.526544

3958.0868899

2623.3232306

3431.4607677

2358.1385337

2552.8319758

2970.995978

1573.3429921

;

run;

proc esm data=test plot=(forecasts);

forecast value / model=damptrend;

run;

 

ForecastsPlot.png

 

*assuming seasonality of 12;

proc esm data=test plot=(forecasts) seasonality=12;

forecast value / model=seasonal;

run;

ForecastsPlot2.png

ehsanmath
Obsidian | Level 7

Hi Udo_sas,

 

I apriciate your effort.

thanks for your input

SteveDenham
Jade | Level 19

One thing that might guarantee non-negativity on the original scale would be to log transform your data prior to fitting the ARIMA model.  You could then post process the forecast values by exponentiating, thereby ensuring that the values are positive.

 

The question then becomes whether the log transformed values meet the distributional assumptions for ARIMA.

 

Steve Denham

udo_sas
SAS Employee

Hello -

As a point for consideration when going for a log transformation approach: given the nature of the exponential function the back-transformed forecasts could be behaving unexpectedly.

Thanks,

Udo

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
  • 4 replies
  • 7419 views
  • 1 like
  • 3 in conversation