# Modelling Time Series Processes using GARCH

To go into the turbulent seas of volatile data and analyze it in a time changing setting, ARCH models were developed.

Pages: 1 2

The range goes from -2.8 to 5.5 with a mean of -0.002. This indicates that the series oscillates around 0 but has a lot of variability which is an ideal candidate for a GARCH modelling technique. To fit a GARCH, we need to identify the ARIMA model on which we will add GARCH. This calls for ACF and PACF plots

acf(inflation_series)

pacf(inflation_series)

Looking at the plots, we can see the third, fourth and fifth lags to be fairly significant. It seems an ARIMA(5,0,0) model should be a good fit for the series. Let’s try and test with the Ljung-Box test

Arima_5_0_0<- arima(inflation_series[1:499], order = c(5,0,0)) #Check out the residuals residual <- Arima_5_0_0$resid acf(residual) pacf(residual)

The first five lags are almost vanishing with no lag showing a significant impact in the ACF plot. Let’s double check with the Ljung Box test. The Ljung Box test is a statistical test to check if any of the autocorrelations are not zero. The higher the p-value, the more chance that all autocorrelations are zero. If the p-value is lower than 0.05, we generally assume with a 95% confidence that some autocorrelations are not zero and our ARIMA fit was inappropriate.

Box.test(residual,c(20),"Ljung-Box")

Box-Ljung test

data: residual

X-squared = 15.321, df = 20, p-value = 0.7578

The p-value is quite high and shows that the fit was good. Now is the time for GARCH fit over ARIMA(5,0,0). Let’s try the popular GARCH(1,1) model. To make things simpler, we will only use the first 500 observations. The garchFit function helps us achieve this

garch.fit <- garchFit(formula = ~arma(5,0)+garch(1,1), data = inflation_series[1:500])

**Conclusion: The beauty of fGarch and available series of plots**

The advantage of fGarch package is that the garchFit function is very rich in functionality. Using the summary statistics provides a lot of tests and statistics. Using the plot function also provides with a lot of graphs and analysis. Let’s try using the plot function on the model

plot(garch.fit)

Make a plot selection (or 0 to exit):

1: Time Series 2: Conditional SD

3: Series with 2 Conditional SD Superimposed 4: ACF of Observations

5: ACF of Squared Observations 6: Cross Correlation

7: Residuals 8: Conditional SDs

9: Standardized Residuals 10: ACF of Standardized Residuals

11: ACF of Squared Standardized Residuals 12: Cross Correlation between r^2 and r

13: QQ-Plot of Standardized Residuals

As we can see, we are presented with a choice of plots. I recommend trying out all the options from 1 to 13 and noting the analysis. For simplicity, I will show a two plots: Time series and Series with 2 Conditional SD Superimposed

1. Time Series

3. Series with 2 Conditional SD Superimposed

This is just the beginning and there are a lot of packages. Different packages have different applications. The fGarch package used in this article is abbreviated for Financial Garch and suited for modelling heteroskedasticity in financial time series such as the exchange rate used from the Garch dataset. Try working on other packages and keep learning. This article provides the required background for Garch modelling with implementation in a financial series. **Here is the entire code** used for reference.

This article was contributed by **Perceptive Analytics**. Madhur Modi, Chaitanya Sagar, Jyothirmayee Thondamallu and Saneesh Veetil contributed to this article.

Perceptive Analytics provides data analytics, data visualization, business intelligence and reporting services to e-commerce, retail, healthcare and pharmaceutical industries. Our client roster includes Fortune 500 and NYSE listed companies in the USA and India.

**Related:**

- Optimization Using R
- Building Regression Models in R using Support Vector Regression
- Propensity Score Matching in R

Pages: 1 2