BookmarkSubscribeRSS Feed

Improve Accuracy by Adding Events in SAS Visual Forecasting 8.5 Model Studio

Started ‎05-20-2020 by
Modified ‎05-20-2020 by
Views 3,235

Events such as holidays, marketing blasts, natural disasters and epidemics can disrupt normal patterns and affect forecasts. For example, hurricanes may temporarily shut down neighborhoods or cities, temporarily reducing electricity usage and hence electricity demand.

 

Adding events can significantly improve the accuracy of our models. SAS Visual Forecasting 8.5 makes it easy to add events and reforecast our dependent variable, giving us even more accurate results.

 

In this article we use the Model Studio interface of SAS Visual Forecasting 8.5 to easily add two types of events:

  • Predefined events (Easter and Thanksgiving)
  • Custom events (Hurricanes)

We will evaluate our model accuracy both before and after adding events.

Background

An event can be any incident that disrupts the normal time series. An event may be a point in time (such as a one-day holiday, like Christmas). Or an event may extend over a period of time, such as a 5-day sale on an item at Amazon. Adding events to our project lets us model the effect that the events have on the dependent time series. When we add an event to a time series, SAS Visual Forecasting creates a dummy indicator variable. This variable is then used as an independent variable for time series modeling and forecasting.

 

Weather disasters can cause massive power outages by knocking down power lines or flooding. On the list of top 10 largest blackouts in U.S. history, there is only one that is not caused by a hurricane. Hurricanes are the leading cause of power outages in the U.S. by a wide margin, according to an Accuweather report and an infogram report.  Severe power outages may disrupt electricity demand and electricity generation. For example, see electric load in the City of Tallahassee following Hurricane Michael’s landfall in 2018.

 

image001.png

https://www.eia.gov/todayinenergy/detail.php?id=37332

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

In this article we use hurricane event data to improve our time series modeling and forecasting of electricity generation in Florida.

Data Set: Florida Electricity Generation 2001-2019

For this article we use Florida electricity generation data from the US Energy Information Administration and hurricane data from Wikipedia. Our first step is to create new SAS Visual Forecasting 8.5 project in SAS Model Studio.

 

image002.png

 

In the Data tab, we assign the appropriate roles to the data. For example, time (Date), the dependent variable (Generation_MWH), and any independent variables.  If you are unfamiliar with Visual Forecasting 8.5, see my GEL online course Using SAS Visual Forecasting 8.5 on SAS Viya 3.5.

 

image003.png

 

Before adding events, we go to the Pipelines tab and Run Pipeline.

 

image004.png

 

Next, we look at the Modeling results in the Forecast Viewer.

 

image005.png

 

In the Modeling pane we see that the best model is DIAG1_REGARIMA1  with a MAPE (Mean Absolute Percent Error) of 1.313. The second best model is DIAG1_ARIMAX1 with a MAPE of 1.332.

 

image007.png

 

These seem pretty good, but let's see if we can improve on them!

Add Predefined Events

Perhaps we believe a couple of predefined events might affect electricity demand and generation. Adding predefined events to our project is very easy. We go to our Data tab, select Predefined events, and click the Add Predefined Events button.

 

image008.png

 

Here we see a list of possible events to add.

 

image009.png

 

Predefined events currently include 22 choices, largely holidays celebrated in the United States and Canada:

  • Boxing Day
  • Canada Day
  • Canada Observed Day
  • Christmas Day
  • Columbus Day
  • Easter Day
  • Fathers Day
  • Halloween
  • Labor Day
  • Memorial Day
  • Martin Luther King Jr.’s Birthday
  • Mothers Day
  • New Year
  • Thanksgiving Day
  • Thanksgiving Day (Canada)
  • Independence Day (US)
  • Abraham Lincoln’s and George Washington’s Birthdays Observed
  • Valentines Day
  • Veterans Day
  • Veterans Day – U.S. Government-Observed
  • Veterans Day – U.S. Post Office Observed
  • Victoria Day

Let’s add Easter and Thanksgiving, and leave the default of Use if significant.

 

image010.png

 

Notice that once you have added Predefined events you cannot delete them from the list, but you could set them to Do not use.

 

image011.png

Florida Hurricanes 2001-2019

Hurricanes can be important events that can cause large scale power outages, temporarily reducing electricity demand and generation. From 2001 to 2019, Florida was hit by eight major hurricanes.

 

image012.png

Create a Customized List of Events in SAS Studio

To create a customized list of hurricanes in Florida we turn to SAS Studio 5.2. Here we use PROC HPFEVENT with the EVENTDEF statement.

 

image013.png

 

The dates used are the dates that each hurricane hit Florida.

 

eventdefcode.png

 

We will use our elecgen2019florida.sas7bdat dataset; any sorted data set could be used to create the event data table. We create the event data table using the OUT option in the EVENTDATA statement. We call the table eventhurr2001to2019 and will make it accessible from the casuser caslib.

 

FULL CODE:

cas MySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
libname casuser cas caslib="casuser";
libname bethout '/home/beeber/sasuser.viya/BethOut';

proc hpfevents data=bethout.elecgen2019florida lead=12;
  id date interval=month;
  eventdef hurricane = '13AUG2004'd '04SEP2004'd '16SEP2004'd '24SEP2004'd
                       '10JUL2005'd '24OCT2005'd '10SEP2017'd '10OCT2018'd;
  eventdata out=casuser.eventhurr2001to2019 (Label = 'Event List');
run;

proc print data=casuser.eventhurr2001to2019;
run;

proc casutil outcaslib="casuser";
  promote casdata="eventhurr2001to2019";
quit;

*cas MySession terminate;

 

The code will create your EVENTDEF (event definition) table, partially shown below:

 

image014-1536x203.png

 

The event definition can also include qualifier options.

 

image015.png

 

For this example, we will not change any defaults or any qualifier options. See the documentation for more information on EVENTDEF options or using the HPFEVENTS procedure, see the documentation.

Import Our Custom Events

Now we will return to our SAS Visual Forecasting 8.5 project in Model Studio to import the custom events table that we just created. In the left pane of the Data tab, click the New Data Source icon and select Events.

 

image016.png

 

In the Choose Data window, type event in the search cell. Select your customized list of events table that you named EVENTHURR2001TO2009. Click OK.

 

image017-1536x697.png

 

Now you see your customized event Hurricane listed in the middle pane. By default, each custom defined event that you add is set to Do not use. We will set to Hurricane to Force use.

 

image018.png

 

Our pipeline is now out-of-date, so we must run it again. Return to the Pipelines tab, Run Pipeline, right click Auto-forecasting node, select Forecast Viewer, go to Modeling tab.

 

We see that our Mean Absolute Percent Error (MAPE) has improved!

 

image019.png

 

compared to the MAPE results we achieved PRIOR to adding our events.

 

image020.png

 

More Advanced:  BY Groups

Notice that we used a data set without by groups.  If we our dataset included all states in the US, we would need to enter separate hurricane dates for each state, i.e., for each by group.  This becomes more complicated.  But don't worry!  Tammy Jackson has your back, and she has written an article, BY Group Processing and EVENTS in SAS Viya, that details just how you can accomplish this!

Other tips:

  • You can add custom events from a Forecast Server project. You will need to import the data set that contains the event definitions. For more information, see Save Events to a SAS Data Set in the SAS Forecast Studio: User’s Guide.
  • If your custom events table has an event with the same name as one that you have already added from predefined events, you cannot add that events table.
  • You cannot add events to an external forecast project.
  • The Naive Model Forecasting modeling strategy does not support events.

For More Information

Version history
Last update:
‎05-20-2020 10:18 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags