R language is a free statistical computing environment; hence there are multiple ways/packages to achieve a particular statistical/quantitative output. I am going to discuss here a concise list of R packages that one can use for the modeling of financial risks and/or portfolio optimization with utmost efficiency and effectiveness. The intended audience for this article is financial market analysts interested in using R, and also for quantitatively inclined folks with a background in finance, statistics, and mathematics.

Given the rise in the frequency of crises (the frequency of occurrence of financial market crises has certainly increased during the last 18 years or so; since the 1999 bubble burst), the modeling and measurement of financial market risk have gained tremendously in importance and the focus of portfolio allocation has shifted from the *average* side of the (*mean**, SD*) coin to the *SD* side. Hence, it has become necessary to devise and employ methods and techniques that are better able to cope with the empirically observed extreme fluctuations in the financial markets. Analysts should go beyond the ordinarily encountered standard tools and techniques. It is better to have a larger set of tools (one of them is certainly R language) available than to be forced to rely on a more restricted set of methods.

__Exploratory Analysis of Financial Market Data__

Packages *fBasics**, evir* and *timeSeries* - are used for reviewing the Stylized facts for univariate series. Use these packages for exploratory data analysis such as percentage returns, box plot of returns, autocorrelations, partial autocorrelations and to investigate basic properties of financial returns and related quantities.

Packages *mts* and *zoo –* are used for reviewing the Stylized facts for multivariate series. Use these packages to analyze the characteristics of multivariate return series, such as co-movement between multiple equity markets etc.

__Modeling For suitable Return Distribution__

Packages *fBasics* and *GeneralizedHyperbolic* – are used for univariate analysis for generalized hyperbolic distribution (GHD) and its special cases, namely the hyperbolic (HYP) and normal inverse Gaussian (NIG) distributions.

Packages *ghyp* and *QRM* – can handle both univariate and multivariate cases for HYP, GHD, NIG and student’s t-distributions. These can also be used to choose the risk measures such as, the standard deviation, the VaR, or the ES, and whether the portfolio should be a minimum risk, a tangency, or a target return portfolio.

Packages *SkewHyperbolic* and *VarianceGamma* **-** *SkewHyperbolic* is solely for the modelling and fitting of the skew hyperbolic Student’s t distribution. **VarianceGamma** can be considered as a twin package to the **SkewHyperbolic** package, but its focus is on the variance gamma distribution.

Packages *Davies, fBasics, gld* and *lmomco* – are used for the generalized lambda distribution (GLD) for risk modelling and data analysis.

__Modeling For Extreme Value Theory__

Packages *evd* and *evdbays* – are used univariate and multivariate parametric extreme value distributions. *evdbayes* provides functions and methods for the Bayesian analysis of extreme value models, where Markov chain Monte Carlo (MCMC) techniques are utilized.

Packages *extRemes* and *in2extRemes* – use them for distribution models such as the generalized extreme value, the Gumbel, the generalized Pareto, and the exponential distributions. The fit can be accomplished to either block maxima data or the threshold excesses.

Package *fExtremes* – use it for data preprocessing, EDA, the GEV distribution, the GPD, and the calculation of risk measures.

Packages *Renext* and *RenextGUI* – they deal explicitly with EVT. A GUI is contained in *RenextGUI.*

* *

__Modeling volatility__

Packages *bayesGARCH, ccgarch, fGarch, GEVStableGarch, gogarch, lgarch (log_garch), rugarch* and *rmgarch* – are a comprehensive suite of packages for GARCH-type models for both univariate and multivariate analysis.

__Modeling dependence__

Package *BLCOP* – The first two letters in the name, BL, stand for Black–Litterman approach and the last three, COP, are for Copula. Hence, use this package for implementing the Black–Litterman approach to portfolio optimization and the framework of copula opinion pooling.

Packages *copula* and *fCopulae* – use them for broad implementation of the copula concept. Archimedean, elliptical, and extreme value copulae can be implemented.

Package *gumbel* – use it solely for Gumbel copula.

__Modeling For Robust Portfolio Optimization__

Package *covRobust* – use it for implementation of the covariance and location estimator introduced by Wang and Raftery.

Package *fPortfolio* – use it for conducting many different kinds of robust portfolio optimization task.

Packages *MASS**,* *lattice**,* *robustbase**, robust,* *rrcov* and *stats* – use these packages for robust estimation for the location vector and scatter, Huber M-estimators, dispersion, minimum covariance determinant, the orthogonalized Gnanadesikan–Kettenring estimators etc..

Package *cccp -* The package’s name is an acronym for “cone constrained convex programs” and as such is suitable for solving convex objective functions with second-order cone constraints.

__Modeling For Diversification of Portfolio__

Packages *cccp,* *DEoptim, DEoptimR, and RcppDE, FRAPO* and *PortfolioAnalytics –* use these packages for finding a portfolio allocation which gives equal marginal contributions to the ES for a given confidence level, the diversification ratio, concentration ratio, volatility-weighted average correlation and risk-measure-related approaches to portfolio optimization etc. They can also be used in other optimizations.

__Modeling for Risk Optimal Portfolios__

Packages *fPortfolio –* use this package for CVaR portfolios (mean excess loss, mean shortfall, and tail VaR), and for producing risk surface plots. Also used for optimizing the minimum-CVaR and minimum-variance portfolios.

Packages *glpkAPI, linprog, lpSolve, lpSolveAPI and Rglpk* **- ** are used for linear programming. Large-scale linear programs as well as mixed integer programs can be solved.

Package *Rsymphony -* provides a high-level interface to the MILP solver SYMPHONY, where the branch, cut, and price approach for solving MILP problems are implemented.

Package *PerformanceAnalytics –* contains functions and methods for assessing the performance of a given portfolio allocation and the associated risks.

__Modeling For Tactical Asset Allocation__

Package *BLCOP* - functions and procedures for the Black–Litterman method. The package also provides functions/methods for determining an optimal portfolio allocation for given prior/posterior distributions.

Packages *dse, fArma, and forecast* – use them for model implementations for univariate and multivariate time series. Package fArma can be used to implement different types of ARMA models - AR, MA, ARMA, ARIMA, and ARFIMA.

Package *MSBVAR* **–** use it to estimate classical and Bayesian (structural) VAR models and carry out inferential analysis on them.

Packages *urca* and *vars*** ** - use the former for the analysis of integrated and co-integrated time series, whereas the latter for the implementation of multivariate time series models and inferences associated with these.

© 2019 Data Science Central ® Powered by

Badges | Report an Issue | Privacy Policy | Terms of Service

**Most Popular Content on DSC**

To not miss this type of content in the future, subscribe to our newsletter.

- Book: Statistics -- New Foundations, Toolbox, and Machine Learning Recipes
- Book: Classification and Regression In a Weekend - With Python
- Book: Applied Stochastic Processes
- Long-range Correlations in Time Series: Modeling, Testing, Case Study
- How to Automatically Determine the Number of Clusters in your Data
- New Machine Learning Cheat Sheet | Old one
- Confidence Intervals Without Pain - With Resampling
- Advanced Machine Learning with Basic Excel
- New Perspectives on Statistical Distributions and Deep Learning
- Fascinating New Results in the Theory of Randomness
- Fast Combinatorial Feature Selection

**Other popular resources**

- Comprehensive Repository of Data Science and ML Resources
- Statistical Concepts Explained in Simple English
- Machine Learning Concepts Explained in One Picture
- 100 Data Science Interview Questions and Answers
- Cheat Sheets | Curated Articles | Search | Jobs | Courses
- Post a Blog | Forum Questions | Books | Salaries | News

**Archives:** 2008-2014 |
2015-2016 |
2017-2019 |
Book 1 |
Book 2 |
More

**Most popular articles**

- Free Book and Resources for DSC Members
- New Perspectives on Statistical Distributions and Deep Learning
- Time series, Growth Modeling and Data Science Wizardy
- Statistical Concepts Explained in Simple English
- Machine Learning Concepts Explained in One Picture
- Comprehensive Repository of Data Science and ML Resources
- Advanced Machine Learning with Basic Excel
- Difference between ML, Data Science, AI, Deep Learning, and Statistics
- Selected Business Analytics, Data Science and ML articles
- How to Automatically Determine the Number of Clusters in your Data
- Fascinating New Results in the Theory of Randomness
- Hire a Data Scientist | Search DSC | Find a Job
- Post a Blog | Forum Questions

## You need to be a member of Data Science Central to add comments!

Join Data Science Central