# R: Book with extensive examples for either portfolio optimization or volatility forecasting?

I'm at a new job and there's the option to use R (you don't have to, but I'd like to). I used R years ago, so I while I'm somewhat familiar with it, I have forgotten most of it. For me, the best approach to get back into this and keep me motivated is to be guided step by step through a practical example. Get it to work and then I work backwards from there to really understand what I was doing. Later I would probably modify it.

At my work, R is mainly used for portfolio optimization, but volatility forecasting especially with GARCH models is also a big topic. So I'm interested in any book (or any other source) that walks me through how to do this. If it explains the theory too, it's great, but I can read up on this somewhere else.

• Since R is not mandatory, have you considered Python? There are more books on Python for finance and I think the knowledge of language itself will provide better utility. – ruslaniv May 24 '20 at 6:57

Have you seen Financial Risk Modelling and Portfolio Optimization with R by Bernhard Pfaff?

There are many R code examples for portfolio selection and some for GARCH models in this book:

@BOOK{Gilli2019,
title        = {Numerical Methods and Optimization in Finance},
year         = 2019,
author       = {Gilli, Manfred and Maringer, Dietmar and Schumann, Enrico},
edition      = 2,
url          = {http://enricoschumann.net/NMOF.htm},
doi          = {10.1016/C2017-0-01621-X}
}


(Disclosure: I am one of the authors.)

There are sample materials available on backtesting and optimisation, though the book contains another chapter dedicated to portfolio selection. There is also an R package NMOF that bundles many functions described in the book; all code examples are available from https://gitlab.com/NMOF/NMOF2-Code .

Some examples that use the NMOF package are on Stack Exchange:

Regularizers to compute Minimum Variance Portfolio weights

target market correlation for long / short equity portfolio

Calculating the efficient frontier from expected returns and SD

CVAR alternatives for optimization

The following book on Time Series and forecasting might be of help for you

Handbook of Financial Time Series

Editors: Andersen, T.G., Davis, R.A., Kreiss, J.-P., Mikosch, Th.V. (Eds.)

This handbook presents a collection of survey articles from a statistical as well as an econometric point of view on the broad and still rapidly developing field of financial time series. It includes most of the relevant topics in the field, from fundamental probabilistic properties of financial time series models to estimation, forecasting, model fitting, extreme value behavior and multivariate modeling for a wide range of GARCH, stochastic volatility, and continuous-time models

• would be great if you could link the chapters to either portfolio construction or volatility forecasting with 2 or 3 sentences (to provide a focused answer to the question). – lehalle May 24 '20 at 7:25
• Thanks for the input. Added description – statmed May 24 '20 at 9:50

Jim Gatheral's The Volatility Surface, A Practitioner's Guide is a good resource for volatility.