Showing posts with label seasonality. Show all posts
Showing posts with label seasonality. Show all posts

Monday, February 6, 2017

Stationarity in time series

Formally: A time series y1,y2,... is nonstationary if, for some m, the joint probability distribution of yi, yi+1, ..., yi+m-1 is dependent on the time index i (definition by WolframMathworld)


Strong form of stationarity: A time series whose joint probability distribution does not change in time


Weak form of stationarity: A time series whose mean and autocovariance do not change in time (i.e. mean is the same at any time and covariance only depends on lag, not on time).


Practically: If the time series appear mean-reverting it is most probably stationary. If, on the contrary, it is drifting up or down, it is probably not. If the autocorrelation function drops to zero quickly on higher lags, it is probably stationary. On the contrary, ACF for non-stationary time series decreases very slowly. "Time series with trends, or with seasonality, are not stationary. A time series with cyclic behavior is stationary - that is because the cycles are not of fixed length, so before we observe the series we cannot be sure where the peaks and troughs of the cycles will be" (Rob J. Hydman: Forecasting: principles and practice).


The problem with non-stationarity is also known as “spurious regression” problem. When dealing with two (or more) non-stationary time series, very high correlation is often found between them, despite lack of any rational causality. What is often overlooked and ignored in many studies is that the correlation and regression coefficients might be misleading if assumptions (non-stationarity) are not met. The problem is that sample estimates of correlation and regression coefficients can not be interpreted as population parameters at all in such case (Johansen: Correlation, regression, and cointegration of nonstationary economic time series).


Treatment of non-stationarity is possible:
  • If there is a deterministic trend, the time series can be in fact “trend stationary process” as it mean-reverts to a level determined for each time t by function f(t) (e.g. linear time trend f(t)=βt). By simply subtracting trend f(t) we obtain stationary process.
  • If the series drifts up or down (the process is not mean-reverting because stochastic shocks persists a.k.a. there is a unit root) then differencing helps. Typical example would be random walk process.
  • If there is deterministic seasonality, set of dummy variables can capture the seasonal component.
  • If there is changing seasonal effect, then seasonal differencing helps.
  • If there is increasing variance, log transformation can be applied (to remedy the variance problem in general, the Box-Cox transformation function helps).


The ultimate goal of non-stationarity remedies should be however to obtain stationary residuals. A model with non-stationary dependent or independent variables should not present a problem as long as model errors are stationary. A prime example would be cointegration model, which is a correct model describing two processes which evolve in an equilibristic relationship.

Tuesday, January 24, 2017

The backshift operator B (aka the lag operator L)

The lagged value can be expressed by means of backshift operator B (sometimes it is called the lag operator L). Having time series yt=1,2…={y1,y2,…} the operator B ’s function is to refer to value lagged n times backwards:

It has standard multiplication and division properties:

It can be also used as a polynomial:

The advantage of B operator is that time series’ differencing Δ can be calculated easily:

The first order difference is for example:

And the (rarely used) second order difference (kind of “derivative”) is:

Not to be confused with seasonal differencing:

For example, having monthly time series, the annual seasonality can be expressed through seasonal differencing:


To continue the example, in combination with first differencing: