<<

Type of variation Stationary Transformations

Simple Descriptive Techniques

Dr. Bo Li

January 9, 2012

Dr. Bo Li Simple Descriptive Techniques Type of variation Stationary time series Transformations Simple Descriptive Techniques

I Descriptive methods should generally be tried before attempting more complicated procedures, because they can be vital in “cleaning” the , and then getting a “feel” for them, before trying to generate ideas a regards a suitable model. I If a time series contains trend, or some other systematic component, the usual summary (e.g., and )can be seriously misleading and should not be calculated. I Moreover, even when a series do not contain any systematic components, the do not have their usual properties. I Focus on ways of understanding typical time-series effects, such as trend, seasonality and correlations between successive observations. Dr. Bo Li Simple Descriptive Techniques Type of variation Stationary time series Transformations Type of variation – decomposing the variation in a series

I Seasonal variation: many time series exhibits variation that is annual in period. For example, unemployment is typically “high” in winter but lower in summer. I Other cyclic variation: apart from seasonal effects, some time series exhibit variation at a fixed period due to some other physical cause. E.g., daily variation in temperature. I Trend: loosely defined as “long term change in the mean level”. Take into account the number of observations available and make a subjective assessment of what is meant by the phrase “long term”. I Other irregular fluctuations: After trend and cyclic variations have been removed, the residuals may or may not be “random”. Check whether any cyclic variation is still left or irregular variation maybe explained in terms of probability models. Dr. Bo Li Simple Descriptive Techniques Type of variation Stationary time series Transformations Example of type of variation

*

80 * * * * * * * * * * * * * * * * * * * * * * * * * 60 * * * * * * * * * * * * * * * * * * * * counts * * 40 * * * * * * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * ** ** * * * * * * ** * * ** * * * * * ** * * * * * * * * * * * * * * * * * * * * * ** * ** ** * * 20 * * * * * * * * * * ** * * * * * * * * * * * * * * * * ** * * * * * * * * * ** * * ** * ** * * * * * * * * * * * * * * 0 *

0 100 200 300

days Hospital admission counts for circulatory (black line) and respiratory (red line) disease in 2002.

Dr. Bo Li Simple Descriptive Techniques Type of variation Stationary time series Transformations Stationary time series

I A time series is said to be stationary if there is no systematic change in mean (no trend), if there is no systematic change in and if strictly periodic variations have been removed.

I Intuitively, the properties of one section of the data are much like those of any other section.

I Strictly speaking, there is no such thing as “stationary time series”, as the stationarity property is defined for a model.

I However, the phrase is often used for time-series data meaning that they exhibit characteristics that suggest a stationary model can sensibly be fitted.

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series and Transformations Three main reasons for transformation

I Stabilize the variance: If there is a trend in the series and the variance appears to increase with the mean, then it may be advisable to transform the data.

I In particular, if the standard deviation is directly proportional to the mean, a logarithmic transformation is indicated. I On the other hand, if the variance changes through time without a trend being present, then a transformation will not help. Instead, a model that allows fro changing variance should be considered.

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Three main reasons for transformation

I Make the seasonal effect additive: If there is a trend in the series and the size of the seasonal effect appears to increase with the mean, then it may be advisable to transform the data so as to make the seasonal effect constant from year to year.

I additive: constant seasonal effect I multiplicative: the size of the seasonal effect is directly proportional to the mean. A logarithmic transformation is appropriate to make the effect additive.

I Make the data normally distributed: model building and forecasting are usually carried out on the assumption that the data are normally distributed. For example, Box-Cox transformation

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Three main reasons for transformation

Use with caution!

I There are problems in practice with transformations in that a transformation, which makes the seasonal effect addtive, may fail to stabilize the variance. Thus it may be impossible to achieve all the above requirement at the same time.

I It is more difficult to interpret and forecasts produced by the transformed model may have to be “transformed back” in order to be of use. This can introduce biasing effects.

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Time Series with a trend

The simplest type of trend is the familiar “linear trend + noise”:

Xt = α + βt + t ,

where α, β are constants and t denotes a random error term with zero mean. The mean level a time t is given by

mt = α + βt

The analysis of a time series that exhibits trend depends on whether one wants to

I measure the trend

I remove the trend in order to analyse the local fluctuations

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Time Series with a trend

Three approaches to describe trend: I Curve fitting: A traditional method of dealing with non-seasonal data that contain a trend, particular yearly data, is to fit a simple function of time such as a polynomial curve (linear, quadratic, etc.).

I The fitted function provides a measure of the trend, and the residuals provide an estimate of local fluctuations, where the residuals are the differences between the observations and the corresponding values of the fitted curve. I Polynomial curve: mt = α + βt, e.g, mt = 0.4 + 2t t I Gompertz curve: log(mt ) = a + br , e.g., t log(mt ) = 3 + 2 × 0.5 a 0.7 I Logistic cruve: mt = 1+be−ct , e.g., mt = 1+0.3e−2t

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Time Series with a trend

Three approaches to describe trend: I Filtering Linear filter converts one time series, xt , into another, yt , by the linear interpolation +s X yt = ar xt+r . r=−q P If ar = 1, the operation is referred to as a . Moving averages are often symmetric with s = q and aj = a−j . 1 e.g. ar = 2q+1 for r = −q,..., +q, and the smoothed value of xt is given by +q 1 X Sm(x ) = x . t 2q + 1 t+r r=−q

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Time Series with a trend

I Filtering Having estimated the trend, we can look at the local fluctuations by examing Res(xt ) = residual from smoothed value Ps = xt − yt = r=−q br xt+r .

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Time Series with a trend

P+∞ I Convolution: ck = r=−∞ ar bk−r

ck = ar ? bj

Example: (1/4, 1/2, 1/4) = (1/2, 1/2) ? (1/2, 1/2)

I Differencing

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Analyzing series that contain seasonal variation

I Three common seasonal models:

A Xt = mt + St + t B Xt = mt St + t C Xt = mt St t

I Smoothing average for monthly, quarterly data...

I Seasonal differencing

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Autocorrelation and correlogram

P (xi −x¯)(yi −y¯) I Sample autocorrelation coefficients r = √ P2 2 (yi −y¯) I Autocorrelation coefficient or serial correlation coefficient PN−k t=1 (xt − x¯)(xt+k − x¯) rk = PN 2 t=1(xt − x¯)

1 PN−k I ck = N t=1 (xt − x¯)(xt+k − x¯). Then, rk = ck /c0 I Correlogram: The plot of sample autocorrelation coefficients rk against k for k = 0, 1, ..., M.

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Autocorrelation and Correlogram

Correlogram is also called sample AutoCorrelation Function (ac.f.) ac.f. for house sales

Series sales 1.0 0.8 0.6 0.4 ACF 0.2 0.0 −0.2 0 5 10 15 20

Lag

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Autocorrelation and Correlogram

ac.f. for wheat price index

Series wheat 1.0 0.8 0.6 ACF 0.4 0.2 0.0

0 5 10 15 20 25

Lag

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Autocorrelation and Correlogram

ac.f. for instrumental temperatures

Series temp$temperature 1.0 0.8 0.6 ACF 0.4 0.2 0.0 −0.2 0 5 10 15 20

Lag

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Autocorrelation and Correlogram

R code to generate the correlogram acf(sales) acf(wheat) acf(temp$temperature) help(acf)

Another Example: x <- 1:100 y <- sin(x) plot(y) plot(y,type=’l’) acf(y)

Dr. Bo Li Simple Descriptive Techniques Type of variation Time series with a trend Stationary time series Autocorrelation and correlogram Transformations Interpreting the correlogram

I Random series

I Short-term correlation

I Alternating series

I Non-stationary series

I Seasonal series

I Outliers

Dr. Bo Li Simple Descriptive Techniques