a Time Series
You're working with a data series that exhibits a clear trend and before processing the data further you need to remove the trend from the data. This is called
Construct a trendline in Excel using one of the techniques discussed in Chapter 8 (see Recipe 6.2 for an introduction to trendlines in Excel). Use the resulting trendline to detrend the original data as discussed in this recipe.
Time series data is often thought of as being comprised of several
. (Some models assume a fourth,
, component.) When analyzing time series data (e.g., when making forecasts based on historical data), it's often desirable to decompose the time series into its various components. To this end, additive or multiplicative models are often used.
represent the ordinates of a time series such that
is some function of time. Then, we can decompose
In these equations,
represents the long-term trend component,
the seasonal component, and
the irregular variation component of the total time series,
. The first equation is a multiplicative model, while the second is an additive model. Which model you decide to use largely depends on the nature of your data and which model yields the best results. For example, when forecasting you might try both models and use whichever model yields the most accurate
. In this and the remaining recipes in this chapter, I'm going to use the multiplicative model; however, you can apply the additive model using very similar Excel techniques.
Figure 6-20 shows historical average annual
for the state of Louisiana from 1970 to 2000. This series exhibits a clear upward trend, highlighted by the linear trendline superimposed over the original data.
Figure 6-20. Annual temperatures from 1970 to 2000
If you were going to make a forecast using this historical data, one of the first steps you'd take would be to detrend the original series to remove the long-term trend component.
Using the multiplicative model, divide both sides of the equation
. This means the detrended series,
, consists only of the seasonal and irregular variation components. To actually compute
, you must first compute a trendline as shown in Figure 6-20 (see Recipe 6.2 or Chapter 8). Then compute the trend value for each year in the series.
, divide the original series ordinate (
) by the computed trend value (
) to yield the detrended series (
). Figure 6-21 shows a portion of the spreadsheet I set up to perform these calculations for the example temperature series.
Figure 6-21. Detrending example spreadsheet
Column B contains the year while column C (under the heading
), contains the original temperature series.
The formula for the trendline shown in Figure 6-20 is
is the year. (This trendline equation was determined using Excel's chart trendline feature; see Recipe 6.2.) Column D (under the heading
), contains this formula for each year. The
formulas in column D are of the form
. This series represents the long-term trend component for the original time series.
Finally, column E (under the heading
Y/T = SI
), contains the detrended series. You simply divide each value in the
column by the corresponding value in the
column to yield
. The cell formulas in the
Y/T = SI
column are of the form
. Figure 6-22 shows the resulting detrended series.
Figure 6-22. Detrended series
If you were to construct a linear trendline for this series, it would simply consist of a horizontal line. The variations shown in Figure 6-22 are around the long-term trend, and they consist of both seasonal components (if present) and irregular variations. Further analysis (e.g., when forecasting), would probably require you to decompose this series even further to remove the seasonal component. This process is called
and is covered in the next two recipes.
There are other methods of detrending a time series besides using the least squares linear trendline used in this example. Sometimes higher-order trendlines are used, while at other times linear trendlines are computed using only the two series values at each end of the time series. Consult a standard text on time series analysis for more detailed information on these and other detrending