Introduction to Time Series I

Author: Edwin Bedolla

Date: Original, 4th April 2020. This version, 7th February 2021.

This document gathers some main concepts in time series analysis as well as some examples written for the Julia programming language.

First, we import every module that will be used in this document.

26.9 μs
59.6 s
4.1 ms

Definitions

  • A time series is a collection of random variables indexed in a ordered set representing time periods.

  • Stochastic processes are a family of indexed random variables Z(ω,t) where ω belongs to a sample space and t belongs to an index set.

  • For a given ω, Z(ω,t) as a function of t is called a sample function or realisation.

  • The population that consists of all possible realisations is called the ensemble.

From these definitions we can see that a time series is actually a stochastic process. We will now turn to see some simple examples of time series and how to program them in Julia.

8.1 μs

Examples

1. White noise

One of the basic time series is white noise, which is a time series generated from uncorrelated variables, which are most of the time normally distributed.

17.5 μs
7.9 μs
41.4 μs
1.6 ms

This collection of random variables {xt} has the following properties:

μx=0

σx2=1

They are independently and identically distributed such that

xti.i.d.N(0,1)

We can see that this time series is very noisy, with big peaks all over the place; if we wanted to do some meaningful analysis on it we might have a difficult time. Instead we can apply a very simple smoothing technique named the moving average.

19.0 μs

2. Moving average

The moving average is an actual time series in itself defined as

vt=1Ni=0N1wti

which means that the moving average takes as input the neighboring values in the past and future time periods and evaluates them, obtaining the realization as an arithmetic mean. The following example applies a moving average to a white noise time series.

24.9 μs
24.2 μs
71.4 μs
267 ms
3.0 ms

In this case we used the following 3-valued moving average

vt=13(wt1+wt+wt+1)

We can see that most of the peaks are gone, but we can still observe the main structure of the original time series.

12.6 μs

3. Random walks with drift

The analysis of trends is one of the prime examples of time series, where there is a need to explore and understand what has been happening throughout several time periods. For example, one might need to understand how the global temperature has been rising since 1997 until today.

To model this type of time series we have the following

xt=δt+j=1twj

where, as before, wj is a white noise time series, with σw=1; δ is the so-called drift coefficient that makes the trend in the time series much more steep. In the special case that we have δ=0 we would have what's called a simple random walk.

We can see an example of a random walk with drift and without drift below.

40.9 μs
18.8 μs
6.5 μs
60.0 ns
84.2 ms
41.1 μs
2.8 ms

Here we see a trend in the time series because every time period in the future the realization is always higher than in past values.We might expect that this time series is always growing. We will see that trends are very useful to perform some basic exploratory analysis on the data itself in further documents.

12.9 μs