Modelling Time Series Processes using GARCH

To go into the turbulent seas of volatile
c
comments

By Perceptive Analytics

Marching towards the ARCH and GARCH

When techniques like linear regression or time series were aimed at modelling the general trend exhibited by a set or series of #Install the Ecdat package
install.packages("Ecdat")
#Loading the library and the Garch dataset
library(Ecdat)
mydata=Garch
#Look at the dataset
str(mydata)
'data.frame': 1867 obs. of 8 variables:
$ date: int 800102 800103 800104 800107 800108 800109 800110 800111 800114 800115 ...
$ day : chr "wednesday" "thursday" "friday" "monday" ...
$ dm : num 0.586 0.584 0.584 0.585 0.582 ...
$ ddm : num NA -0.004103 0.000856 0.001881 -0.004967 ...
$ bp : num 2.25 2.24 2.24 2.26 2.26 ...
$ cd : num 0.855 0.855 0.857 0.854 0.855 ...
$ dy : num 0.00421 0.00419 0.00427 0.00432 0.00426 ...
$ sf : num 0.636 0.636 0.635 0.637 0.633 ...


We notice that the data types are a bit mismatched. We need to convert date to date format and day to factor before proceeding further. The rest of the features are exchange rates and are in correct format

#Correct the data types of date and day
#Correcting date fixes it to some arbitrary date such that the trend is same but the mapping is different
mydata$date=as.Date(mydata$date, origin = "01-02-1980")
mydata$day=as.factor(mydata$day)


Let’s include the other packages. We will use fGarch function to perform our analysis

#Install packages and load them
install.packages("tseries")
install.packages("urca")
install.packages("fUnitRoots")
install.packages("forecast")
install.packages("fGarch")
library(fGarch) # estimate GARCH and Forecast
library(tseries) #used for time series data
library(urca) #Used for checking Unit root Cointegration
library(fUnitRoots) #Used for conducting unit root test
library(forecast) #Used for forecasting ARIMA model


Let’s convert the dataset into a time series now

#Converting Dollar - Deutsche mark exchange rate to time series
exchange_rate_dollar_deutsch_mark <- ts(mydata$dm, start=c(1980, 1), end=c(1987, 5), frequency=266) #Plot the time series plot.ts(exchange_rate_dollar_deutsch_mark, main="exchange_rate_dollar_deutsch_mark")


Image

We have a lot of small variations across the years as visible from the plot. The next step is to start processing the data. For this, we take the difference of the values. Though we already have the ddm column which provides us the difference, I am calculating the difference separately as the log of the exchange rate and then multiplying it with 100 as it serves as a better representation of the variation. Remember, in economic terms, the difference of the exchange rates is also represented by inflation/deflation as the case may be.

#Calculate inflation as difference of log of exchange rate and then multiplied by 100
inflation_series<-(diff(log(exchange_rate_dollar_deutsch_mark)))*100 #Plot the inflation plot.ts(inflation_series, main="Inflation of exchange rate")


Image
 

This is the inflation residual on which represents the variability in the original time series. There is a continuous variation without a definite trend or pattern. It even has some spikes such as the one between the years 1985 and 1986 of about 5.5. This is the series which can be adequately captured by using a GARCH model. To make things more clear, we will also see the summary statistics of the inflation series.

summary(inflation_series)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.822000 -0.451700 -0.026770 -0.002183 0.428900 5.502000