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:
We will evaluate our model accuracy both before and after adding events.
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.
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.
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.
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.
Before adding events, we go to the Pipelines tab and Run Pipeline.
Next, we look at the Modeling results in the Forecast Viewer.
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.
These seem pretty good, but let's see if we can improve on them!
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.
Here we see a list of possible events to add.
Predefined events currently include 22 choices, largely holidays celebrated in the United States and Canada:
Let’s add Easter and Thanksgiving, and leave the default of Use if significant.
Notice that once you have added Predefined events you cannot delete them from the list, but you could set them to Do not use.
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.
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.
The dates used are the dates that each hurricane hit Florida.
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.
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:
The event definition can also include qualifier options.
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.
In the Choose Data window, type event in the search cell. Select your customized list of events table that you named EVENTHURR2001TO2009. Click OK.
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.
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!
compared to the MAPE results we achieved PRIOR to adding our events.
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!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.