A Complete Introduction To Time Series Analysis (with R):: Differencing

Hair Parra
Analytics Vidhya
Published in
6 min readJun 19, 2020

--

Applying differencing to a Time Series can remove both the trend and seasonal components

In the last two articles , we studied the classical decomposition model, which allows us to interpret our time series the following way:

Using this powerful assumption, we can further estimate both the trend and the season, so that we have a better idea of what our series is actually “made of”. For instance, we could use the moving-average filter to estimate the trend, then estimating seasonality and carrying a classical analysis. In this article, we will learn a powerful technique to remove trend and sometimes even seasonality simultaneously: differencing. Let’s see what this is all about! For this, we will make use of two important operators: the backward shift operator and the difference operator.

Backward Shift Operator

Just as it names implies, if we are given some observation at time X, the backward shift operator simply outputs the previous observation in time. Note that we can apply it more than once, which gives

That is, applied j-times at time t, it returns back the (t-j)’th observation.

Lag-1 Difference Operator

--

--

Hair Parra
Analytics Vidhya

Data Scientist & Data Engineer. CS, Stats & Linguistics graduate. Polyglot.