Download Introduction to Time Series Forecasting

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Regression analysis wikipedia , lookup

Choice modelling wikipedia , lookup

Exponential smoothing wikipedia , lookup

Linear regression wikipedia , lookup

Coefficient of determination wikipedia , lookup

Data assimilation wikipedia , lookup

Transcript
Using Statistical Data to Make Decisions
Module 6: Introduction to Time Series Forecasting
Titus Awokuse and Tom Ilvento,
University of Delaware, College of Agriculture and Natural Resources,
Food and Resource Economics
The last module examined the multiple regression
modeling techniques as a tool for analyzing financial
data. Multiple regression is a commonly used
technique for explaining the relationship between several
variables of interest. Although financial analysts are
interested in explaining the relationship between correlated
variables, they also want to know the future trend of key
variables. Business managers and policymakers regularly
use forecasts of financial variables to help make important
decisions about production, purchases, market conditions,
and other choices about the best allocation of resources.
How are these decisions made and what forecasting
techniques are used? Are the forecasts accurate and
reliable?
T
This module introduces some basic skills for analyzing and
forecasting data over time. We will discuss several
forecasting techniques and how they are used in generating
forecasts. Furthermore, we will also examine important
issues on how to evaluate and judge the accuracy of
forecasts and discuss some of the common challenges to
developing good forecasts.
Key Objectives
• Understand
the
basic
components of forecasting
including qualitative and
quantitative techniques
• Understand the three types of
time series forecasts
• Understand
the
basic
characteristics and terms of
forecasts
• See an example of a forecast
using trend analysis
In this Module We Will:
• Run a time series forecast
with trend data using Excel
BASICS OF FORECASTING
Time series are any univariate or multivariate quantitative
data collected over time either by private or government
agencies. Common uses of time series data include: 1)
modeling the relationships between various time series; 2)
forecasting the underlying behavior of the data; and 3)
forecasting what effect changes in one variable may have on
the future behavior of another variable. There are two major
categories of forecasting approaches: Qualitative and
Quantitative.
• Compare a linear and
nonlinear trend analysis
Qualitative Techniques: Qualitative techniques refer to a
number of forecasting approaches based on subjective
estimates from informed experts. Usually, no statistical data
analysis is involved. Rather, estimates are based on a
deliberative process of a group of experts, based on their
For more information, contact:
Tom Ilvento
213 Townsend Hall, Newark, DE 19717
302-831-6773
[email protected]
Using Statistical Data to Make Decisions: Time Series Forecasting
past knowledge and experience. Examples are the Delphi
technique and scenario writing, where a panel of experts are
asked a series of questions on future trends, the answers
are recorded and shared back to the panel, and the process
is repeated so that the panel builds a shared scenario. The
key to these approaches is a recognition that forecasting is
subjective, but if we involve knowledgeable people in a
process we may get good insights into future scenarios.
This approach is useful when good data are not available, or
we wish to gain general insights through the opinions of
experts.
Quantitative Techniques: refers to forecasting based on
the analysis of historical data using statistical principles and
concepts. The quantitative forecasting approach is further
sub-divided into two parts: causal techniques and time series
techniques. Causal techniques are based on regression
analysis that examines the relationship between the variable
to be forecasted and other explanatory variables. In contrast,
Time Series techniques usually use historical data for only
the variable of interest to forecast its future values (See
Table 1 below).
Table 1. Alternative Forecasting Approaches
Categories
Application
Specific Techniques
Qualitative
Techniques
Useful when
historical data are
scare or non-existent
Delphi Technique
Scenario Writing
Visionary Forecast
Historic Analogies
Casual
Techniques
Useful when
historical data are
available for both the
dependent (forecast)
and the independent
variables
Regression Models
Econometric Models
Leading Indicators
Correlation Methods
Time
Series
Techniques
Useful when
historical data exists
for forecast variable
and the data exhibits
a pattern
Moving Average
Autoregression Models
Seasonal Regression
Models
Exponential Smoothing
Trend Projection
Cointegration Models
Forecast horizon: The forecast horizon is defined as the
number of time periods between the current period and the
date of a future forecast. For example, for the case of
monthly data, if the current period is month T, then a forecast
of sales for month T+3 has a forecast horizon of three steps.
For quarterly data, a step is one quarter (three months), but
Page 2
Using Statistical Data to Make Decisions: Time Series Forecasting
for annual data, one step is one year (twelve months). The
forecast changes with the forecast horizon. The choice of the
best and most appropriate forecasting models and strategy
usually depends on the forecasting horizon.
Three Types of Time Series Forecasts
Point Forecast: a single number or a "best guess." It does
not provide information on the level of uncertainty around the
point estimate/forecast. For example, an economist may
forecast a 10.5% growth in unemployment over the next six
months.
Interval Forecast: relative to a point forecast, this is a range
of forecasted values which is expected to include the actual
observed value with some probability. For example, an
economist may forecast growth in unemployment rate to be
in the interval, 8.5% to 12.5%. An interval forecast is related
to the concept of confidence intervals.
Density Forecast: this type of forecast provides information
on the overall probability distribution of the future values of
the time series of interest. For example, the density forecast
of future unemployment rate growth might be normally
distributed with a mean of 8.3% and a standard deviation of
1.5%. Relative to the point forecast, both the density and the
interval forecasts provide more information since we provide
more than a single estimate, and we provide a probability
context for the estimate. However, despite the importance
and more comprehensive information contained in density
and interval forecasts, they are rarely used by businesses.
Rather, the point forecast is the most commonly used type
of forecast by businesses managers and policymakers.
CHARACTERISTICS OF TIME SERIES
Any given time series can be divided into four categories:
trend, seasonal components, cyclical components, and
random fluctuations.
Trend. The trend is a long-term, persistent downward or
upward change in the time series value. It represents the
general tendency of a variable over an extended time period.
We usually observe a steady increase or decline in the
values of a time series over a given time period. We can
characterize an observed trend as linear or non-linear. For
example, a data plot of U.S. overall retail sales data over the
1955-1996 time period exhibits an upward trend, which may
be reflecting the increase in the purchases of consumer
durables and non-durables over time (See Figure 1). The
Page 3
Using Statistical Data to Make Decisions: Time Series Forecasting
$200,000
$175,000
$150,000
$125,000
$100,000
$75,000
$50,000
$25,000
$0
O
ct
-5
Ju 4
n5
M 7
ar
-6
D 0
ec
-6
Se 2
p6
Ju 5
n6
M 8
ar
-7
D 1
ec
-7
3
A
ug
-7
M 6
ay
-7
Fe 9
b8
N 2
ov
-8
4
A
ug
-8
M 7
ay
-9
Ja 0
n9
O 3
ct
-9
5
Ju
l-9
8
Millions Dollars
Monthly U.S. Retail Sales, 1955 to 1996
Monthly Trend
Figure 1. Time Series Plot of Monthly U.S. Retail
Sales, 1955 to 1996
plot in Figure 1 shows a nonlinear trend - sales were
increasing at an increasing rate. This type of relationship is
a curvilinear trend best represented by a polynomial
regression.
Seasonal Components. Seasonal components to a time
series refer to a regular change in the data values of a time
series that occurs at the same time every year. This is a
very common characteristic of financial and other business
related data. The seasonal repetition may be exact
(deterministic seasonality) or approximate (stochastic
seasonality). Sources of seasonality are technologies,
preferences, and institutions that are linked to specific times
of the year. It may be appropriate to remove seasonality
before modeling macroeconomic time series (seasonally
adjusted series) since the emphasis is usually on
nonseasonal fluctuations of macroeconomic series.
However, the removal of seasonal components is not
appropriate when forecasting business variables. It is
important to account for all possible sources of variation in
business time series.
Se
p03
ec
-0
0
D
98
ar
M
Ju
n95
Se
p92
200
180
160
140
120
100
80
60
40
20
0
Ja
n90
Thousands of Starts
U.S. Monthly Housing Starts, 1990 to 2003
Figure 2. Graph of Seasonal Fluctuations in Housing
Starts
Page 4
Using Statistical Data to Make Decisions: Time Series Forecasting
For example, retail sales of many household and clothing
products are very high during the fourth quarter of the year.
This is a reflection of Christmas seasonal purchases. Also,
as shown in Figure 2, housing starts exhibits seasonal
patterns as most houses are started in the spring while the
winter period shows very low numbers of home construction
due to the colder weather. Figure 3 shows the same data,
seasonally adjusted by the Census Bureau. Notice now the
regular pattern of sharp fluctuations has disappeared from
the adjusted figures.
U.S. Monthly Housing Starts Adjusted for
Seasonality, 1990 to 2003
150
100
50
-0
3
Se
p
0
-0
D
ec
M
ar
-
98
95
Ju
n-
Se
p
Ja
-9
2
0
n90
Thousands of Starts
200
Figure 3. Seasonally Adjust Housing Starts
Cyclical Components: refer to periodic increases and
decreases that are observed over more than a one-year
period. In contrast to seasonal components, these types of
variation are also known as business cycles. They cover a
longer time period and are not subject to a systematic
pattern that is easily predictable. Cyclical variation can
produce peak periods known as booms, and trough periods
known as recessions. Although economist may try, it is not
easy to predict economic booms and recessions.
Random (Irregular) Components: refer to irregular
variations in time series that are not due to any of the three
time series components: trend, seasonality, and cyclical.
This is also known as residual or error component. This
component is not predictable and is usually eliminated from
the time series through data smoothing techniques.
Stationary Time Series refers to a time series without a
trend, seasonal, or cyclical components. A stationary time
series contains only a random error component.
Analysis of time series always assumes that the value of the
variable, Yt, at time period t, is equal to the sum of the four
components and is represented by:
Yt = Tt + St +Ct + Rt
Page 5
Using Statistical Data to Make Decisions: Time Series Forecasting
TIME SERIES DATA MODIFICATION STRATEGIES
When dealing with data over time, there are several things
we might do to adjust, smooth, or otherwise modify data
before we begin our analysis. Some of these strategies are
relatively straightforward while others involve a more
elaborate model which requires decisions on our part.
Within the regression format that we are emphasizing, some
of these techniques can be built into the regression model as
an alternative to modifying the data.
Adjusting For Inflation. Often time series data involve
financial variables, such as income, expenditures, or
revenues. Financial data over time are influenced by
inflation. The longer the time series (in years), the more
potential for inflation to be a factor in the data. With financial
data over time, part of the trend may simply be a reflection
of inflation. While there may be an upward trend in sales,
part of the result might be a function of inflation and not real
growth.
The dominant strategy to deal with inflation is to adjust the
data by the Consumer Price Index (CPI), or a similar index
that is geared toward a specific commodity or sector of the
economy. For example, we might use a health care index
when dealing with health expenditures because this sector of
the economy has experienced higher inflation than general
commodities. The CPI is an index based on a basket of
market goods. The Bureau of Labor Statistics calculates
these indices on an annual basis, often breaking it down by
region of the country and commodity. There are many
places to find the consumer price index. The following are
two useful Internet sites which contain CPI indices as well as
definitions and discussions about their use.
Bureau of Labor http://www.bls.gov/cpi/home.htm#overview
Minneapolis
Federal
Reserve
Bank
http://minneapolisfed.org/Research/data/us/calc/index.cfm
Using the CPI to adjust your data is relatively straight
forward. The index is often based on 100 and is centered
around a particular year. The other years are expressed as
being above (>100) or below (<100) the base year.
However, any year can be thought of the base year. In order
to adjust our data for inflation in Excel, we would obtain the
CPI index for the years in our time series and use this index
to create a new variable which is expressed in dollars for one
of the time periods. An example is given in Table 2. The
base year is 2002, so a CPI Ratio is calculated as the CPI for
2002 (179.9) divided by each years CPI. The CPI ratio is
then multiplied by the Loss figure to calculate an adjusted
loss, expressed in 2002 dollars.
Page 6
Using Statistical Data to Make Decisions: Time Series Forecasting
Table 2. U.S. Flood Insurance Losses Adjusted by
the CPI for 2002 Dollars, Partial Table, 1978 to 2002
Loss1
$147,719
$483,281
$230,414
$127,118
$198,296
Trend
1978
1979
1980
1981
1982
CPI
CPI Ratio Adj Loss
65.2
2.76 $407,587
72.6
2.48 $1,197,552
82.4
2.18 $503,053
90.9
1.98 $251,579
96.5
1.86 $369,673
1997
160.5
1998
163.0
1999
166.6
2000
172.2
2001
177.1
2002
179.9
1
Loss data are expressed in $1,000s
$519,416
$885,658
$754,150
$250,796
$1,268,446
$338,624
1.12 $582,199
1.10 $977,484
1.08 $814,355
1.04 $262,010
1.02 $1,288,500
1.00 $338,624
Seasonal Data. Data that reflect a regular pattern that is
tied to a time of year is referred to as seasonal data.
Seasonal data will show up on a graph as a regular hills
and valleys in the data across the trend. The seasons
may reflect quarters, months, or some other regular
reoccurring time period throughout the year. The best way
to think of seasonal variations is that part of the pattern in
the data reflect a seasonal component.
In most cases we expect the seasonal variations and are
not terribly concerned with explaining them. However, we
do want to account for them when we make our estimate
of the trend in the data. Seasonal variations may mask or
impede our ability to model a trend. We can account for
seasonal data in one of two main ways. The first is to
deseasonalize the data by adjusting the data for seasonal
effects. This often is done for us when we use
government data that has already been adjusted. The
second method is to account for the seasons within our
model. In regression based models this is done through
the use of dummy variables. In the latter approach, we
use dummy variables to account for quarters (3 dummy
variables) or months (11 dummy variables).
The deseasonal adjustment is done through a ratio-tomoving-average method. The exact computations to do
this are beyond the scope of this module. The
computations, while involved and at times tedious, are not
difficult to do with a spreadsheet program. This approach
involves the following basic steps.
1. Calculate moving averages based on the number of
seasons (4 for quarters, 12 for months)
2. Calculate a centered moving average when dealing
with an even number of seasons. The center is the
average of two successive moving averages to
Page 7
Using Statistical Data to Make Decisions: Time Series Forecasting
center around a particular season. For example, the
average of quarters 1 to 4, and quarters 2 to 5, would
be added together and divided by two to give a
centered moving average for quarter 3.
3. Calculate a ratio to moving average of a specific
season’s value by dividing the value by its centered
moving average
4. Calculate an average ratio to moving average for each
of the seasons in the time series, referred to as a
seasonal index
5. Use this seasonal index to adjust each season in the
time series
Data are often available from secondary sources already
adjusted. The Housing Start data used in this Module
included data that were seasonally adjusted through a
similar, but more sophisticated method as listed above.
Whenever possible, use data that have already been
adjusted by the agency or source that created the data.
Most likely they will have the best method, experience, and
knowledge to adjust the data. Using seasonally adjusted
data in a modeling technique, such as regression, allows
us to make a better estimate of the trend in the data.
However, when we want to make a future prediction of
forecast with a model using deseasonalized data, we need
to add back in the seasonal component. In essence we
have to readjust the forecast using the seasonal index to
make an accurate forecast.
The regression approach to deal with seasonal variations
is to include the seasons into the model. This is done
through the use of dummy variables. By including dummy
variables that represent the seasons we are accounting for
seasonal variation in the model. If the seasons are
quarters (4 time periods), we will include three dummy
variables with one quarter represented in the reference
category. If the seasons are months, we will include 11
dummy variables with one month as the reference
category. It does not matter which season is the reference
category, but we must always have k-1 dummy variables in
the model (where k equals the number of seasons).
Let’s look at an example of the regression approach which
uses the U.S. monthly housing starts from 1990 to 2003.
The data show a strong seasonal effect, as might be
expected. Housing starts are highest in the spring through
summer and lowest in November through February. There
is a strong upward trend in the data which reflects growth
in housing starts over time. Figure 2 shows this upward
Page 8
Using Statistical Data to Make Decisions: Time Series Forecasting
trend with season fluctuations. The R2 for the trend in the
data is .45 and the estimate of the slope coefficient is
.3609 (data not shown).
The seasonal adjusted data provide a much better fit with
a R2 = .78 and the estimate of the slope coefficient for the
trend is .3589 (data not shown). We have to be careful in
comparing R2 across these models because the
dependent variable is not the same in both models, but
clearly removing the seasonal component helped to
improve the fit of the trend. The last model is the original
data, unadjusted for seasonal variations, but dummy
variables representing the months are included in the
model. Since there are 12 months, 11 dummy variables
were included in the model, labeled M1 (January) through
M11 (November). The reference month is December and
is represented in the intercept.
The regression output from Excel is included in Table 3.
The model shows significant improvement over the first
model and R2 increases from .45 to .87. Including the
dummy variables for the months improved the fit of the
model dramatically. The estimate for the slope coefficient
for the trend is very similar to that estimated in the
adjusted data (.3576). If we focus on the dummy
variables, we can see that the coefficients for M1
(January) and M2 (February) are not significantly different
from zero, indicating that housing starts for January and
February are not significantly different as those for
December, the reference category in the model. All the
other dummy variable coefficients are significantly different
from zero and follow an expected pattern - the coefficients
are positive and get larger as we move toward the summer
months.
Both the deseasonalized model and the regression model
with dummy season variables fit the data quite well. It is
also comforting that the estimate for the trend is very
similar in both models. Either approach will provide a
simple but good model to make forecasts. The regression
approach seemed to be the best model had the added
advantage that forecasts from the model will directly
include the seasonal component, unlike the
deseasonalized model. The regression approach with
dummy variables for season is relatively straight-forward
and can easily be modeled with Excel.
Page 9
Using Statistical Data to Make Decisions: Time Series Forecasting
Table 3. Regression Output of Housing Start Data Including Seasonal
Dummy Variables
Regression Statistics
0.934
Multiple R
0.872
R Square
0.862
Adjusted R Square
9.725
Standard Error
168
Observations
ANOVA
Regression
Residual
Total
Intercept
Trend
M1
M2
M3
M4
M5
M6
M7
M8
M9
M10
M11
df
SS
12 100092.725
155 14659.199
167 114751.924
Coef Std Error
67.6221
2.950
0.3576
0.016
-5.5877
3.680
-1.6310
3.679
24.5399
3.678
37.1823
3.678
41.8604
3.677
41.6957
3.677
37.3452
3.677
35.1662
3.676
29.4943
3.676
33.4652
3.676
12.3076
3.676
MS
8341.060
94.575
F
88.195
t Stat
P-value
22.921
0.000
23.056
0.000
-1.519
0.131
-0.443
0.658
6.671
0.000
10.110
0.000
11.383
0.000
11.340
0.000
10.158
0.000
9.566
0.000
8.023
0.000
9.104
0.000
3.348
0.001
Data Smoothing. Data smoothing is a strategy to modify
the data through a model to remove the random spikes
and jerks in the data. We will look at two smoothing
techniques, both of which are available in Excel - moving
averages and exponential smoothing. Smoothing can be
thought of as an alternative modeling approach to
regression, or as an intermediate step to prepare the data
for analysis in regression.
The Moving Averages approach replaces data with an
average of past values. In essence it fits a relatively
simple model to the data which uses an average to model
the data points. The rationale behind this approach is to
not allow a single data point to have too much influence on
the trend, by tempering it with observations surrounding or
prior to the value. The result should provide modified data
that shows the direction of the trend, but without the
random noise that can hide or distort. The data are
replaced with an average of past values that move forward
Sig F
0.000
Page 10
Using Statistical Data to Make Decisions: Time Series Forecasting
by a set span. For example, if we have annual data, we
might replace each value with a span of a three or five
year average. We would calculate the averages based on
successive data points that move forward over time, so
that each three year average uses two old and one new
data point to calculate the new average. Please note,
some approaches to moving averages have the modified
value surrounded by the observations used in the average
(some observations before the value and some after).
Excel exclusively uses past values to calculate the moving
average, so that the first three observations are used to
estimate an average for the third observation in a 3-period
moving average.
With a three year average, we will lose two data points in
our series because we can’t calculate an average for the
first or second year. The number of time periods for our
moving average is a decision point which is influenced by
the length of our series, the time units involved, and our
experiences with the volatility of the data. If I have annual
data for 20 years, I might not feel comfortable with a 5year moving average because I would lose too many data
points (four). However, if the data were collected monthly
over the 20 years, a five or six month moving average
would not be a limitation. We want to pick a number that
provides a reasonable number of time periods so that
extreme values are tempered in the series, but we don’t
want to lose too much information by picking a time span
for the average that is too large. The longer the period of
the span for the moving average, the less influence
extreme values have in the calculation, and thus the
smoother the data will be. However, too many
observations in the calculation will distort the trend by
smoothing out all of the trend. The decision point for the
span (or interval in Excel) is part art and part science, and
often requires an iterative process guided by experience.
Let’s look at an example with Excel using the housing start
data. The data are given in months, and the series, from
1990 to 2003, provided 168 time periods. We have
enough data to have flexibility with a longer moving
average. I will use a 6 month moving average. In Excel
this is accomplished fairly easily using the following
commands.
Tools
Data Analysis
Moving Average
Page 11
Using Statistical Data to Make Decisions: Time Series Forecasting
It is wise to insert a blank column in the worksheet where
you want the results to go and to label that column in
advance. Within the Moving Average Menu, the options
are relatively simple.
Input Range
The source of the original time
series
Labels
A check box of whether the first row
contains a label
Interval
The span of the moving average,
given as an integer (such as a 3, 4,
or 5 period moving average)
Output Range
Where you want the new data to go
(you only need to specify the first
cell of the column). Excel will only
put the results in the current
worksheet. Please note, if you used
a label for the original data, Excel
will not create a label for the moving
average. Therefore you should
specify the first row of the data
series, not the first label row.
Chart Output
Excel provides a scatter plot of the
original data and the smoothed data
Standard Errors
Excel will calculate standard errors
of the estimates compared with the
original data. Each calculated
standard error is based on the
interval specified for the moving
average.
The following table is part of the output for the housing
start data (see Table 4). You can see that with a 6 interval
moving average (translated as a 6-month moving average
for our data), the first five observations are undefined for
the new series. The sixth value is simply the sum of the
first six observations, divided by 6.
Value = (99.20+86.90+108.50+119.00+212.10+117.80)/6
Value = 108.75
The next value is calculated in a similar way:
Value = (86.90+108.50+119.00+212.10+117.80+111.20)/6
Value = 110.75
Page 12
Using Statistical Data to Make Decisions: Time Series Forecasting
Table 4. Partial Excel Output of a 6-Month Moving
Average of the Housing Start Data
Housing Starts
6-Month Avg
99.20
#N/A
86.90
#N/A
108.50
#N/A
119.00
#N/A
121.10
#N/A
117.80
108.75
111.20
110.75
102.80
113.40
93.10
110.83
The graph below shows the 6-month moving average data
for housing starts plotted over time. The data still shows
an upward trend with seasonal fluctuations, but clearly the
revised data have removed some of the noise in the
original time series. Moving averages is a simple and
easy way to adjust the data, even if it is a first step before
further analysis with more sophisticated methods. Care
must be taken in choosing the span of the average - too
little will not help, but too much risks smoothing the trend.
Experience and an iterative approach usually guide most
attempts at moving averages.
Se
p03
ec
-0
0
D
98
ar
M
Ju
n95
Se
p92
180
160
140
120
100
80
60
40
20
0
Ja
n90
Thousands of Starts
U.S. Monthly Housing Starts based on 6-Month
Moving Averages, 1990 to 2003
Figure 4. Graph of a 6-Month Moving Average for U.S.
Housing Starts, 1990 to 2003
Page 13
Using Statistical Data to Make Decisions: Time Series Forecasting
Exponential Smoothing. Another approach at smoothing
time series data is exponential smoothing. It forecasts
data on a weighted average of past observations, but it
places more weight on more recent observations to make
its estimates. The model for exponential smoothing is
more complicated than that of moving averages. The
equations for exponential smoothing follow this format.
Ft+1 = Ft + "(yt - Ft)
Ft+1 = "yt + (1-")Ft
or
where: Ft+1 = forecast value for period t+1
yt = Actual value for period t
Ft = Forecast value for period t
" = Alpha (a smoothing constant where (0 # " #1)
From this equation we can see that the forecast for the
next period will equal the forecast mode for this period plus
or minus an adjustment. We won’t have to worry too much
about the equations because Excel will make the
calculations for us. However, we will have to specify the
constant, ". Alpha (") will be a value between zero and
one and it reflects how much weight is given to distant past
values of y when making our forecast. A very low value of
" (.1 to .3) means that more weight is given to past
values, whereas a high value of " (.6 or higher) means
that more weight is given to recent values and the forecast
reacts more quickly to changes in the series. In this sense
" is similar to the span in a moving average - low values of
" are analogous to a higher span. You are required to
choose alpha when forecasting with exponential
smoothing. Excel uses a default value of .3.
In Excel exponential smoothing is accomplished fairly
easily using the following commands.
Tools
Data Analysis
Exponential Smoothing
It is wise to insert a blank column in the worksheet where
you want the results to go and to label that column in
advance. Within the Exponential Smoothing Menu, the
options are relatively simple.
Page 14
Using Statistical Data to Make Decisions: Time Series Forecasting
Input Range
The source of the original time
series
Damping Factor
The level of (1-alpha). The default
is .3.
Labels
A check box of whether the first row
contains a label
Output Range
Where you want the new data to go
(you only need to specify the first
cell of the column). Excel will only
put the results in the current
worksheet. Please note, if you used
a label for the original data, Excel
will not create a label for the
exponential smoothing. Therefore
you should specify the first row of
the data series, not the first label
row, for the output.
Chart Output
Excel provides a scatter plot of the
original data and the smoothed data
Standard Errors
Excel will calculate standard errors
of the estimates compared with the
original data.
The graph below shows the exponential smoothing data
for housing starts plotted over time. The data still shows
an upward trend with seasonal fluctuations, but like the
moving average example the revised data have removed
some of the noise in the original time series. Exponential
smoothing is a bit more complicated approach and
requires software to do it well. There are several models
to choose from (not identified here), some of which can
incorporate seasonal variability. Like moving averages,
exponential smoothing may be a first step before further
analysis with more sophisticated methods. Care must be
taken in choosing the level of alpha for the model.
Experience and an iterative approach usually guide most
attempts at exponential smoothing.
200
150
100
50
Se
p03
ec
-0
0
D
98
ar
M
Ju
n95
Se
p92
0
Ja
n90
Thousands of Starts
U.S. Monthly Housing Starts based on Exponential
Smoothing (alpha = .3), 1990 to 2003
Figure 5. Example of Exponential Smoothing of the
Housing Start Data
Page 15
Using Statistical Data to Make Decisions: Time Series Forecasting
STEPS TO MODELING AND FORECASTING TIME
SERIES
Step 1: Determine Characteristics/Components of
Series
Some time series techniques require the elimination of all
components (trend, seasonal, cyclical) except the random
fluctuation in the data. Such techniques require modeling
and forecasting with stationary time series. In contrast,
other methods are only applicable to a time series with the
trend component in addition to a random component.
Hence, it is important to first identify the form of the time
series in order to ascertain which components are present.
All business data have a random component. Since the
random component cannot be predicted, we need to
remove it via averaging or data smoothing. The cyclical
component usually requires the availability of long data
sets with minimum of two repetitions of the cycle. For
example, a 10-year cycle requires, at least 20 years of
data. This data requirement often makes it unfeasible to
account for the cyclical component in most business and
industry forecasting analysis. Thus, business data is
usually inspected for both trend and seasonal
components.
How can we detect trend component?
•
•
Inspect time series data plot
Regression analysis to fit trend line to data and
check p-value for time trend coefficient
How can we detect seasonal component?
•
•
•
Requires at least two years worth of data at higher
frequencies (monthly, quarterly)
Inspect a folded annual time series data plot - each
year superimposed on others
Check Durbin-Watson regression analysis
diagnostic for serial correlation
Step 2: Select Potential Forecasting Techniques
For business and financial time series, only trend and
random components need to be considered. Figure 3
summarizes the potential choices of forecasting
techniques for alternative forms of time series. For
example, for stationary time series (only random
component exist), the appropriate approach are stationary
forecasting methods such as moving averages, weighted
Page 16
Using Statistical Data to Make Decisions: Time Series Forecasting
Page 17
Time Series Data
Trend Component Exists?
No
Yes
Seasonal Component Exist?
No
Yes
Seasonal Component Exist?
Yes
No
Stationary
Forecasting Methods
Seasonal
Forecasting Methods
Trend
Forecasting Methods
Naïve
Seasonal Multiple Regression
Linear Trend Projection
Moving Average
Seasonal Autoregression
Non-linear Trend
Weighted Moving Average
Time Series Decomposition
Projection
Exponential Smoothing
Figure 6. Potential Choices of Forecasting Techniques
moving average, and exponential smoothing. These
methods usually produce less accurate forecasts if the
time series is non-stationary. Time series methods that
account for trend or seasonal techniques are best for
non-stationary business and financial data. These
methods include: seasonal multiple regression, trend and
seasonal autoregression, and time series decomposition.
Trend Autoregression
Using Statistical Data to Make Decisions: Time Series Forecasting
Step 3: Evaluate Forecasts From Potential Techniques
After deciding on which alternative methods are suitable
for available data, the next step is to evaluate how well
each method performs in forecasting the time series.
Measures such as R2 and the sign and magnitude of the
regression coefficients will help provide a general
assessment of our models. However, for forecasting, an
examination of the error terms from the model is usually
the best strategy for assessing performance.
First, each method is used to forecast the data series.
Second, the forecast from each method is evaluated to
see how well it fits relative to the actual historical data.
Forecast fit is based on taking the difference between
individual forecast and the actual value. This exercise
produces the forecast errors. Instead of examining
individual forecast errors, it is preferable and much easier
to evaluate a single measurement of overall forecast error
for the entire data under analysis. Error (et) on individual
forecast, the difference between the actual value and the
forecast of that value, is given as:
et = Yt - Ft
Where:
et = the error of the forecast
Yt = the actual value
Ft = the forecast value
There are several alternative methods for computing
overall forecast error. Examples of forecast error
measures include: mean absolute deviation (MAD), mean
error (ME), mean square error (MSE), root mean square
error (RMSE), mean percentage error (MPE), and mean
absolute percentage error (MAPE). The best forecast
model is that with the smallest overall error measurement
value. The choice of which error criteria are appropriate
depends on the forecaster’s business goals, knowledge of
data, and personal preferences. The next section
presents the formulas and a brief description of five
alternative overall measures of forecast errors.
Page 18
Using Statistical Data to Make Decisions: Time Series Forecasting
1) Mean Error (ME)
A quick way of computing forecast errors is the mean error
(ME) which is a simple average of all the errors of forecast
for a time series data. This involves the summing of all the
individual forecast errors and dividing by the number of
forecast. The formula for calculating mean absolute
deviation is given as:
N
ME =
∑e
i
i =1
N
An issue with this measure is that if forecasts are both
over (positive errors) and below (negative errors) the
actual values, ME will include some cancellation effects
that may potentially misrepresent the actual magnitude of
the forecast error.
2) Mean Absolute Deviation (MAD)
The mean absolute deviation (MAD) is the mean or
average of the absolute values of the errors. The formula
for calculating mean absolute deviation is given as:
N
MAD =
∑
i =1
ei
N
Relative to the mean error (ME), the mean absolute
deviation (MAD) is commonly used because by taking the
absolute values of the errors, it avoids the issues with the
canceling effects of the positive and negative values. N
denotes the number of forecasts.
3) Mean Square Error (MSE)
Another popular way of computing forecast errors is the
mean square error (MSE) which is computed by squaring
each error and then taking a simple average of all the
squared errors of forecast. This involves the summing of
all the individual squared forecast errors and dividing by
the number of forecast. The formula for calculating mean
square error is given as:
Page 19
Using Statistical Data to Make Decisions: Time Series Forecasting
N
MSE =
∑e
i =1
2
i
N
The MSE is preferred by some because it also avoids the
problem of the canceling effects of positive and negative
values of forecast errors.
4) Mean Percentage Error (MPE)
Instead of evaluating errors in terms of absolute values,
we sometimes compute forecast errors as a percentage of
the actual values. The mean percent error (MPE) is the
ratio of the error to the actual value being forecast
multiplied by 100. The formula for calculating mean
percent error is given as:
∑(
)
N
MPE =
i =1
ei
Yi
⋅ 100
N
5) Mean Absolute Percentage Error (MAPE)
Similar to the mean percent error (MPE), the mean
absolute percent error (MAPE) is the average of the
absolute values of the percentage of the forecast errors.
The formula for calculating mean absolute percent error is
given as:
∑(
N
MAPE =
i =1
ei
Yi
)
⋅ 100
N
The MAPE is another measure that also circumvents the
problem of the canceling effects of positive and negative
values of forecast errors.
Page 20
Using Statistical Data to Make Decisions: Time Series Forecasting
TWO EXAMPLES OF FORECASTING TECHNIQUES
Forecasting Time Series with Trend
The first example will focus on modeling data with a trend.
For this example we will look at monthly U.S. Retail Sales
data from Jan. 1955 to Jan. 1996. The data are given in
million of dollars and are not seasonally adjusted or
adjusted for inflation. We know there is a curvilinear
relationship in this data, so we will be able to see how
much better we can do in our estimates by estimating a
second order polynomial to the data.
Our strategy will be the following:
1. Examine the scatter plot of the data
2. Decide on two alternative models, one linear and the
other nonlinear
3. Split the sample into two parts. The first part will be
designated as the “estimation sample.” It contains
most of the data and be used to estimate the two
models (1955:1 to 1993:12). The second part of the
data is called the “validation sample” and will be used
to assess the ability of the models to forecast into the
future.
4. After we determine which model is best, we will reestimate the preferred model using all the data. This
model will be used to make future forecasts.
The plot of the data shows an upward trend, but the trend
appears to be increasing at an increasing rate (see Figure
7). A second order polynomial could provide a better fit to
this data and will be used as an alternative model to the
simple linear trend.
$200,000
$175,000
$150,000
$125,000
$100,000
$75,000
$50,000
$25,000
$0
O
ct
-5
Ju 4
n5
M 7
ar
-6
D 0
ec
-6
Se 2
p6
Ju 5
n6
M 8
ar
-7
D 1
ec
-7
3
A
ug
-7
M 6
ay
-7
Fe 9
b8
N 2
ov
-8
4
A
ug
-8
M 7
ay
-9
Ja 0
n9
O 3
ct
-9
5
Ju
l-9
8
Millions Dollars
Monthly U.S. Retail Sales, 1955 to 1996
Monthly Trend
Figure 7. U.S. Monthly Retail Sales, 1955 to 1996
Page 21
Using Statistical Data to Make Decisions: Time Series Forecasting
Page 22
Linear Trend Regression. The first model is a linear
regression of Retail Sales from January 1955 to December
1993. The Excel Regression output is given below in
Table 5. The R2 for the model is fairly high, .89. The
coefficient for trend is positive and significantly different
from zero. The estimated regression equation is:
Yt = -15,826.216 + 329.955(Trend)
I used the residual option in Excel to calculate columns of
predicted values and residuals for the data. From these I
was able to calculate the Mean Absolute Difference
(MAD), Mean Percentage Error (MPE), and the Mean
Absolute Percentage Error (MAPE). The average values
for the data in the analysis for each sample are give below.
MAD
MPE
MAPE
Average
Estimation Sample
13920.40
6.50
41.34
Average Validation
Sample
37556.53
20.71
20.71
These figures are not easy to interpret on their own, but
they will make more sense once we compare them to the
second model. However, if you look at the residuals you
would notice that there are long strings of consecutive
positive residuals followed by strings of negative residuals
(data not shown). This pattern repeats itself several times.
The pattern reflects that the relationship is nonlinear and
the model systematically misses the curve of the data.
Table 5. Regression of Monthly Retail Sales on Trend
Regression Statistics
0.942
Multiple R
0.888
R Square
0.888
Adjusted R Square
15853.125
Standard Error
468
Observations
ANOVA
df
Regression
Residual
Total
Intercept
Trend
SS
MS
1 929960937041.49 929960937041.49
466 117115854291.71
251321575.73
467 1047076791333.20
Coef
-15826.216
329.955
Std Error
1467.974
5.424
t Stat
-10.781
60.830
F
3700.28
P-value
0.000
0.000
Sig F
0.000
Using Statistical Data to Make Decisions: Time Series Forecasting
Page 23
Polynomial Trend Regression. The alternative model is
a polynomial or quadratic model of the form:
Yt = bo + b1Trend + b2Trend2
This model is linear in the parameters, but will fit a curve to
the data. The form of the curve depends upon the signs of
the coefficients for b1 and b2. If b2 is negative, the curve
will show an increasing function at a decreasing rate,
eventually turning down. If it is positive, the curve will
increase at an increasing rate. The regression output of
the polynomial equation is given in Table 6. R2 for this
model is much higher, .997, which indicates that adding
the squared trend term in the model improved the fit. The
coefficient for Trend2 is positive and significant (p< .001).
Once again I used the residual option in Excel to calculate
MAD, MPE, and MAPE for the estimation sample and the
validation sample. The following table contains the results
of this analysis. Each of the summary error measures are
smaller for the polynomial regression, indicating the
second model fits the data better and will provide better
forecasts.
Average Estimation
Sample
Average Validation
Sample
MAD
MPE
MAPE
2307.65
0.06
6.07
3303.41
-1.77
1.88
Table 6. Polynomial Regression of U.S. Monthly Sales on Trend
and Trend Squared
Regression Statistics
0.998
Multiple R
0.997
R Square
0.997
Adjusted R Square
2725.375
Standard Error
468
Observations
ANOVA
df
Regression
Residual
Total
Intercept
Trend
TrendSq
SS
MS
2 1043622925925.31 521811462962.65
465
3453865407.89
7427667.54
467 1047076791333.20
Coef
19245.229
-117.765
0.955
Std Error
379.562
3.738
0.008
t Stat
50.704
-31.509
123.703
F
70252.40
P-value
0.000
0.000
0.000
Sig F
0.000
Using Statistical Data to Make Decisions: Time Series Forecasting
Forecasting Time Series with Seasonality
This second example focuses on how to estimate and
forecast time series that exhibit seasonality. A relatively
straightforward approach to modeling and forecasting
seasonality is through the use of dummy variables in
multiple regressions to represent the seasons. Dummy or
indicator variables were introduced earlier in the modules
on simple and multiple regressions. Dummy variables are
used to represent qualitative variables in a regression.
Recall that for any k categories, only k-1 dummy variables
are needed to represent it in a regression. For example,
we can represent quarterly time series with three dummy
variables and monthly series by eleven dummy variables.
The excluded quarter or month is known as the reference
category. For example, the complete model for a monthly
time series can be specified as follows:
Yt = bo + b1*Time + b2*M1+ b3*M2+ b4*M3+ b5*M4+ b6*M5+
b7*M6+ b8*M7+ b9*M8+ b10*M9+ b11*M10+ b12M11
where:
•
bo is the intercept
•
b1 is the coefficient for the time trend component
•
b2, b3, …, b12 are the coefficients that indicate how
much each month differs from the reference month,
month 12 (December).
•
M1, M2, …, M11 are the dummy variables for the first 11
months (= 1 if the observation is from the specified
month, otherwise =0)
•
Yt is the monthly number of U.S. housing starts, in
1,000s
Using the U.S. Housing Starts used earlier, we illustrate
how to produce out-of-sample forecast for a data with a
monthly seasonal component. First, we analyze the
monthly time series plot of the data and identify a seasonal
component in the time series. Then we create 11 monthly
seasonal dummy variables. Although we will use
December as the reference category, any of the months
can be chosen as the reference month. Next, divide the
data set into two sub-samples. The first sub-sample will
be designated as the "estimation sample" while the second
sub-sample represents the "validation sample." Then, we
estimate seasonal dummy variable regression model with
the estimation sample (1990:1 - 2002:12) and hold out
some data as the validation sample 2003:1 - 2003:12) to
validate the accuracy of the trend regression forecasting
Page 24
Using Statistical Data to Make Decisions: Time Series Forecasting
models. The model without the seasonal dummies is
shown in the graph below (see Figure 8). The R2 for this
model is low, only .45.
200
180
160
140
120
100
80
60
40
20
0
03
Se
p-
0
-0
D
ec
M
ar
-9
8
5
n9
Ju
92
y = 0.0119x - 298.14
2
R = 0.4482
Se
p-
Ja
n-
90
Thousands of Starts
U.S. Monthly Housing Starts, 1990 to 2003
Figure 8. Simple Linear Regression of U.S. Monthly
Housing Starts on Trend, 1990 to 2003
A full model is then estimated for the data from January
1990 to December 2002 (estimation sample). The Excel
output is in Table 7. The full model dramatically improves
R2 to .864. We can assume that most of the remaining
variation is due to the cyclical component of the time
series. However, this model is only designed to capture
the seasonal (and trend) component. Note that all the
seasonal dummies (except JAN and FEB dummies) are
statistically significant as shown by their very low p-values.
This implies that the seasonal regression model is a good
model for forecasting this time series. The seasonal
effects are relatively low in the winter months, but rise
quickly in the spring when most home construction gets
started. The seasonal effects seem to have peaked by the
month of June Including the dummy variables for month
has improved the fit of the model.
The estimated regression coefficients are then used to
generate the error measures for the estimation sample
and the validation sample, as shown below. The figures
for MAD, MPE, and MAPE are all reasonable for this
model, for both the estimation sample and the validation
sample. Given the partial nature of the model, which only
account for seasonal effects, the measures of forecast
error looks reasonable. In order to obtain a more reliable
forecast with lower errors, we will need to account for the
cyclical factors in the macroeconomic data for housing
starts. Overall, the model fits the data well.
Average Estimation
Sample
Average Validation
Sample
MAD
MPE
MAPE
7.18
-0.81
6.56
10.16
3.36
6.61
Page 25
Using Statistical Data to Make Decisions: Time Series Forecasting
Table 7. Regression of Housing Starts on Trend and Season
Regression Statistics
0.934
Multiple R
0.872
R Square
Adjusted R Square 0.862
9.725
Standard Error
168
Observations
ANOVA
Regression
Residual
Total
12
155
167
df
SS
100092.72
14659.20
114751.92
MS
8341.06
94.58
F
88.19
Intercept
Trend
M1
M2
M3
M4
M5
M6
M7
M8
M9
M10
M11
Coef
67.622
0.358
-5.588
-1.631
24.540
37.182
41.860
41.696
37.345
35.166
29.494
33.465
12.308
Std Error
2.950
0.016
3.680
3.679
3.678
3.678
3.677
3.677
3.677
3.676
3.676
3.676
3.676
t Stat
P-value
22.921
0.000
23.056
0.000
-1.519
0.131
-0.443
0.658
6.671
0.000
10.110
0.000
11.383
0.000
11.340
0.000
10.158
0.000
9.566
0.000
8.023
0.000
9.104
0.000
3.348
0.001
CONCLUSION
This module introduced various methods available for
developing forecasts from financial data. We defined
some forecasting terms and also discussed some
important issues for analyzing and forecasting data over
time. In addition, we examined alternative ways to evaluate
and judge the accuracy of forecasts and discuss some of
the common challenges to developing good forecasts.
Although mastering the techniques is very important,
equally important is the forecaster’s knowledge of the
business problems and good familiarity with the data and
its limitations. Finally, the quality of forecasts from any
time series model is highly dependent on the quality and
quantity of data (information) available when forecasts are
made. This is another way of saying “Garbage in, garbage
out.”
Sig F
0.000
Page 26