<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/volatility-modelling-in-r-exercises-part-4/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/07/17/volatility-modelling-in-r-exercises-part-4/?utm_source=rss&utm_medium=rss&utm_campaign=volatility-modelling-in-r-exercises-part-4"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/07/unnamed-chunk-1-7-1.png" target="_blank"><img alt="" src="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/07/unnamed-chunk-1-7-1.png?resize=150%2C150" class="wp-image-5754" data-recalc-dims="1"></a></p>
<p>This is the fourth part of the series on volatility modelling. For other parts of the series follow the tag <a rel="nofollow" href="http://www.r-exercises.com/tag/volatility/" target="_blank">volatility</a>.</p>
<p>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.</p>
<p>Answers to the exercises are available <a rel="nofollow" href="http://r-exercises.com/2017/07/17/volatility-modelling-in-r-part-4-solutions/" target="_blank">here</a>.</p>
<p><strong>Exercise 1</strong><br>
Load the <code>rugarch</code> and the <code>FinTS</code> packages. Next, load the <code>m.ibmspln</code> dataset from the <code>FinTS</code> package. This dataset contains monthly excess returns of the S&amp;P500 index and IBM stock from Jan-1926 to Dec-1999 (Ruey Tsay (2005) Analysis of Financial Time Series, 2nd ed. ,Wiley, chapter 3).<br>
Also, load the <code>forecast</code> package which we will use for autocorrelation graphs.</p>
<p><strong>Exercise 2</strong><br>
Estimate a GARCH(1,1)-M model for the S&amp;P500 excess returns series. Determine if the effect of volatility on asset returns is significant.</p>
<p><strong>Exercise 3</strong><br>
Excess IBM stock returns are defined as a regular zoo variable. Convert this to a time series variable with correct dates.</p>
<div>
<aside><img src="http://www.r-exercises.com/2017/07/17/volatility-modelling-in-r-exercises-part-4/?utm_source=rss&utm_medium=rss&utm_campaign=volatility-modelling-in-r-exercises-part-4"></aside>
<div><strong>Learn more</strong> about Model Evaluation in the online course <a rel="nofollow" href="http://www.r-exercises.com/product/regression-machine-learning-with-r/" target="_blank">Regression Machine Learning with R</a>. In this course you will learn how to:
<ul>
<li>Avoid model over-fitting using cross-validation for optimal parameter selection</li>
<li>Explore maximum margin methods such as best penalty of error term support vector machines with linear and non-linear kernels.</li>
<li>And much more</li>
</ul>
</div>
</div>
<p><strong>Exercise 4</strong><br>
Plot the absolute and squared excess IBM stock returns along with its ACF and PACF graphs and determine the appropriate model configuration.</p>
<p><strong>Exercise 5</strong><br>
The exponential GARCH model incorporates asymmetric effects for positive and negative asset returns. Estimate an AR(1)-EGARCH(1,1) model for the IBM series.</p>
<p><strong>Exercise 6</strong><br>
Using the results from exercise-5, get rolling window forecasts starting from the 800th observation and refit the model after every three observations.</p>
<p><strong>Exercise 7</strong><br>
Estimate an AR(1)-GARCH(1,1) model for the IBM series and get a bootstrap forecast for the next 50 periods with 500 replications.</p>
<p><strong>Exercise 8</strong><br>
Plot the forecasted returns and sigma with bootstrap error bands.</p>
<p><strong>Exercise 9</strong><br>
We can use Monte-Carlo simulation to get a distribution of the parameter estimates. Using the fitted model from exercise-7, run the simulation for 500 periods for a horizon of 2000 periods.</p>
<p><strong>Exercise 10</strong><br>
Plot the density functions of the parameter estimates.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/07/10/volatility-modelling-in-r-exercises-part-3/" title="Volatility modelling in R exercises (Part-3)" target="_blank">Volatility modelling in R exercises (Part-3) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/07/03/volatility-modelling-in-r-exercises-part-2/" title="Volatility modelling in R exercises (Part-2)" target="_blank">Volatility modelling in R exercises (Part-2) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/05/05/forecasting-arimax-model-exercises-part-5/" title="Forecasting: ARIMAX Model Exercises (Part-5)" target="_blank">Forecasting: ARIMAX Model Exercises (Part-5) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.r-exercises.com/2017/07/17/volatility-modelling-in-r-exercises-part-4/?utm_source=rss&utm_medium=rss&utm_campaign=volatility-modelling-in-r-exercises-part-4"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/THR0GnsPo3c" height="1"></a></div>