12 April 2019

Motivation

Time series analysis is central tool in economics, physics, process and quality control, inventory studies, and many others fields.

The starting point for a good analysis is to get a good understanding of the data by making some exploratory analyses.

This simple app, built with the R package shiny, shows a few techniques that can be used to analyse data in R.

In the next slides a brief presentation of the data set and examples of the tecniques used is given.

Have fun!

Data set

Seatbelts dataset is a multivariate time series collecting monthly information of serious car accidents happened in Great Britain between January 1969 and December 1984.

Seatbelts[1:8,]
##      DriversKilled drivers front rear   kms PetrolPrice VanKilled law
## [1,]           107    1687   867  269  9059   0.1029718        12   0
## [2,]            97    1508   825  265  7685   0.1023630         6   0
## [3,]           102    1507   806  319  9963   0.1020625        12   0
## [4,]            87    1385   814  407 10955   0.1008733         8   0
## [5,]           119    1632   991  454 11823   0.1010197        10   0
## [6,]           106    1511   945  427 12391   0.1005812        13   0
## [7,]           110    1559  1004  522 13460   0.1037740        11   0
## [8,]           106    1630  1091  536 14055   0.1040764         6   0

Technique 1: moving average

# smooths data by averaging over sliding time-windows
library(forecast)# x=ts object, order= length of time-window
mov_av<-ma(x=ts(rnorm(1000)),order=50);plot(mov_av)

Technique 2: cross-correlation

# cross-correlation at different lags between two ts objects
ccf(x=ts(rnorm(1000)),y=ts(rnorm(1000)),lag.max=10,type="correlation")