This is the fourth part of the series on volatility modelling. For other parts of the series follow the tag volatility. In this exercise set we will explore GARCH-M and E-GARCH models. We will also use these models to generate rolling window forecasts, bootstrap forecasts and perform simulations. Answers to the exercises are available here. […]

## Volatility modelling in R (Part-4) solutions

Below are the solutions to these exercises on volatility modelling. ############### # # # Exercise 1 # # # ############### library(rugarch) ## Warning: package ‘rugarch’ was built under R version 3.3.3 library(FinTS) ## Warning: package ‘FinTS’ was built under R version 3.3.3 ## Warning: package ‘zoo’ was built under R version 3.3.3 library(forecast) ## Warning: […]

## Volatility modelling in R exercises (Part-3)

This is the third part of the series on volatility modelling. For other parts of the series follow the tag volatility. In this exercise set we will use GARCH models to forecast volatility. Answers to the exercises are available here. Exercise 1 Load the rugarch and the FinTS packages. Next, load the m.ibmspln dataset from […]

## Volatility modelling in R (Part-3) solutions

Below are the solutions to these exercises on volatility modelling. ############### # # # Exercise 1 # # # ############### library(rugarch) ## Warning: package ‘rugarch’ was built under R version 3.3.3 library(FinTS) ## Warning: package ‘FinTS’ was built under R version 3.3.3 ## Warning: package ‘zoo’ was built under R version 3.3.3 library(forecast) ## Warning: […]

## Volatility modelling in R exercises (Part-2)

This is the second part of the series on volatility modelling. For other parts of the series follow the tag volatility. In this exercise set we will use the dmbp dataset from part-1 and extend our analysis to GARCH (Generalized Autoregressive Conditional Heteroscedasticity) models. Answers to the exercises are available here. Exercise 1 Load the […]

## Volatility modelling in R (Part-2) solutions

Below are the solutions to these exercises on volatility modelling. ############### # # # Exercise 1 # # # ############### library(rugarch) ## Warning: package ‘rugarch’ was built under R version 3.3.3 data("dmbp") rets <- ts(dmbp$V1) ############### # # # Exercise 2 # # # ############### garch1.mod = ugarchspec(variance.model = list(garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)), fixed.pars=list(mu=0, omega=0.2, […]

## Volatility modelling in R exercises (Part-1)

Volatility modelling is typically used for high frequency financial data. Asset returns are typically uncorrelated while the variation of asset prices (volatility) tends to be correlated across time. In this exercise set we will use the rugarch package (package description: here) to implement the ARCH (Autoregressive Conditional Heteroskedasticity) model in R. Answers to the exercises […]

## Volatility modelling in R (Part-1) solutions

Below are the solutions to these exercises on volatility modelling. ############### # # # Exercise 1 # # # ############### library(rugarch) ## Warning: package ‘rugarch’ was built under R version 3.3.3 data("dmbp") ############### # # # Exercise 2 # # # ############### rets <- ts(dmbp$V1) plot(rets) ############### # # # Exercise 3 # # # […]

## Ridge regression in R exercises

Bias vs Variance tradeoff is always encountered in applying supervised learning algorithms. Least squares regression provides a good fit for the training set but can suffer from high variance which lowers predictive ability. To counter this problem, we can regularize the beta coefficients by employing a penalization term. Ridge regression applies l2 penalty to the […]

## Ridge regression in R solutions

Below are the solutions to these exercises on ridge regression. ############### # # # Exercise 1 # # # ############### library(lars) library(glmnet) ## Warning: package ‘glmnet’ was built under R version 3.3.3 ## Warning: package ‘foreach’ was built under R version 3.3.3 data(diabetes) attach(diabetes) set.seed(1234) par(mfrow=c(2,5)) for(i in 1:10){ plot(x[,i], y) abline(lm(y~x[,i])) } layout(1) model_ols […]