Besides these packages, a very wide variety of functions suitable for empirical work in Finance is provided by both the basic R system (and its set of recommended core packages), and a number of other packages on the Comprehensive R Archive Network (CRAN). Consequently, several of the other CRAN Task Views may contain suitable packages, in particular the Econometrics, Multivariate, Optimization, Robust, SocialSciences and TimeSeries Task Views.
The ctv package supports these Task Views. Its functions install.views and update.views allow, respectively, installation or update of packages from a given Task View; the option coreOnly can restrict operations to packages labeled as core below.
Contributions are always welcome, and encouraged. Since the start of this CRAN task view in April 2005, most contributions have arrived as email suggestions. The source file for this particular task view file now also reside in a GitHub repository (see below) so that pull requests are also possible.
Standard regression models
- A detailed overview of the available regression methodologies is provided by the Econometrics task view. This is complemented by the Robust task view, which focuses on more robust and resistant methods.
- Linear models such as ordinary least squares (OLS) can be estimated by lm() (from by the stats package contained in the basic R distribution). Maximum Likelihood (ML) estimation can be undertaken with the standard optim() function. Many other suitable methods are listed in the Optimization view. Non-linear least squares can be estimated with the nls() function, as well as with nlme() from the nlme package.
- For the linear model, a variety of regression diagnostic tests are provided by the car, lmtest, strucchange, urca, and sandwich packages. The Rcmdr and Zelig packages provide user interfaces that may be of interest as well.
- A detailed overview of tools for time series analysis can be found in the TimeSeries task view. Below a brief overview of the most important methods in finance is given.
- Classical time series functionality is provided by the arima() and KalmanLike() commands in the basic R distribution.
- The dse and timsac packages provide a variety of more advanced estimation methods; fracdiff can estimate fractionally integrated series; longmemo covers related material. The fractal provide fractal time series modeling functionality.
- For volatility modeling, the standard GARCH(1,1) model can be estimated with the garch() function in the tseries package. Rmetrics (see below) contains the fGarch package which has additional models. The rugarch package can be used to model a variety of univariate GARCH models with extensions such as ARFIMA, in-mean, external regressors and various other specifications; with methods for fit, forecast, simulation, inference and plotting are provided too. The rmgarch builds on it to provide the ability to estimate several multivariate GARCH models. The betategarch package can estimate and simulate the Beta-t-EGARCH model by Harvey. The bayesGARCH package can perform Bayesian estimation of a GARCH(1,1) model with Student’s t innovations. For multivariate models, the gogarch package provides functions for generalized orthogonal GARCH models. The gets package (which was preceded by a related package AutoSEARCH) provides automated general-to-specific model selection of the mean and log-volatility of a log-ARCH-X model. The GEVStableGarch package can fit ARMA-GARCH or ARMA-APARCH models with GEV and stable conditional distributions. The lgarch package can estimate and fit log-Garch models.
- Unit root and cointegration tests are provided by tseries, and urca. The Rmetrics packages timeSeries and fMultivar contain a number of estimation functions for ARMA, GARCH, long memory models, unit roots and more. The CADFtest package implements the Hansen unit root test.
- dlm package provides Bayesian and likelihood analysis of dynamic linear models (i.e. linear Gaussian state space models).
- The vars package offer estimation, diagnostics, forecasting and error decomposition of VAR and SVAR model in a classical framework.
- The dyn and dynlm packages are suitable for dynamic (linear) regression models.
- Several packages provide wavelet analysis functionality: rwt, wavelets, waveslim, wavethresh. Some methods from chaos theory are provided by the package tseriesChaos. tsDyn adds time series analysis based on dynamical systems theory.
- The forecast package adds functions for forecasting problems.
- The tsfa package provides functions for time series factor analysis.
- The stochvol package implements Bayesian estimation of stochastic volatility using Markov Chain Monte Carlo, and factorstochvol extends this to the multivariate case.
- The MSGARCH package adds methods to fit (by Maximum Likelihood or Bayesian), simulate, and forecast various Markov-Switching GARCH processes.
- The DriftBurstHypothesis package estimates a t-test statistics for the explosive drift burst hypothesis (Christensen, Oomen and Reno, 2018).
- The Rmetrics suite of packages comprises fAssets, fBasics, fBonds, timeDate (formerly: fCalendar), fCopulae, fExoticOptions, fExtremes, fGarch, fImport, fNonlinear, fOptions, fPortfolio, fRegression, timeSeries (formerly: fSeries), fTrading, and contains a very large number of relevant functions for different aspect of empirical and computational finance.
- The RQuantLib package provides several option-pricing functions as well as some fixed-income functionality from the QuantLib project to R. The RcppQuantuccia provides a smaller subset of QuantLib functionality as a header-only library; at current only some calendaring functionality is exposed.
- The quantmod package offers a number of functions for quantitative modelling in finance as well as data acquisition, plotting and other utilities.
- The portfolio package contains classes for equity portfolio management; the portfolioSim builds a related simulation framework. The backtest offers tools to explore portfolio-based hypotheses about financial instruments. The pa package offers performance attribution functionality for equity portfolios.
- The PerformanceAnalytics package contains a large number of functions for portfolio performance calculations and risk management.
- The TTR contains functions to construct technical trading rules in R.
- The sde package provides simulation and inference functionality for stochastic differential equations.
- The YieldCurve package contains methods for the estimation of zero-coupon yield curves and spread curves based the parametric Nelson and Siegel (1987) method with the Svensson (1994) extension. The former package adds the McCulloch (1975) cubic splines approach, the latter package adds the Diebold and Li approach. The SmithWilsonYieldCurve construct the yield curve using the Smith-Wilson approach based on LIBOR and SWAP rates.
- The vrtest package contains a number of variance ratio tests for the weak-form of the efficient markets hypothesis.
- The gmm package provides generalized method of moments (GMM) estimations function that are often used when estimating the parameters of the moment conditions implied by an asset pricing model.
- The tawny package contains estimator based on random matrix theory as well as shrinkage methods to remove sampling noise when estimating sample covariance matrices.
- The BurStFin and BurStMisc package has a collection of function for Finance including the estimation of covariance matrices.
- The AmericanCallOpt package contains a pricer for different American call options.
- The VarSwapPrice package can price a variance swap via a portfolio of European options contracts.
- The FinAsym package implements the Lee and Ready (1991) and Easley and O’Hara (1987) tests for, respectively, trade direction, and probability of informed trading.
- The parma package provides support for portfolio allocation and risk management applications.
- The GUIDE package provides a GUI for DE rivatives and contains numerous pricer examples as well as interactive 2d and 3d plots to study these pricing functions.
- The SharpeR package contains a collection of tools for analyzing significance of trading strategies, based on the Sharpe ratio and overfit of the same.
- The RND package implements various functions to extract risk-neutral densities from option prices.
- The LSMonteCarlo package can price American Options via the Least Squares Monte Carlo method.
- The BenfordTests package provides seven statistical tests and support functions for determining if numerical data could conform to Benford’s law.
- The OptHedging package values call and put option portfolio and implements an optimal hedging strategy.
- The markovchain package provides functionality to easily handle and analyse discrete Markov chains.
- The ycinterextra package models yield curve interpolation and extrapolation using via the Nelson-Siegel, Svensson, or Smith-Wilson models, as well as Hermite cubic splines.
- The tvm package models provides functions for time value of money such as cashflows and yield curves.
- The MarkowitzR package provides functions to test the statistical significance of Markowitz portfolios.
- The pbo package models the probability of backtest overfitting, performance degradation, probability of loss, and the stochastic dominance when analysing trading strategies.
- The OptionPricing package implements efficient Monte Carlo algorithms for the price and the sensitivities of Asian and European Options under Geometric Brownian Motion.
- The matchingMarkets package implements a structural estimator to correct for the bias arising from endogenous matching (e.g. group formation in microfinance or matching of firms and venture capitalists).
- The restimizeapi package interfaces the API at www.estimize.com which provides crowd-sourced earnings estimates.
- The credule package is another pricer for credit default swaps.
- The obAnalytics package analyses and visualizes information from events in limit order book data.
- The derivmkts package adds a set of pricing and expository functions useful in teaching derivatives markets.
- The PortfolioEffectHFT package provides portfolio analysis suitable for intra-day and high-frequency data, and also interfaces the PortfolioEffect service.
- The ragtop package prices equity derivatives under an extension to Black and Scholes supporting default under a power-law link price and hazard rate.
- The sharpeRratio package adds moment-free estimation of Sharpe ratios.
- The QuantTools package offers enhanced quantitative trading and modeling tools.
- The pinbasic package adds tools for fast and stable estimates the Probability of Informed Trading (PIN) by Easley et al, and offers factorizations of the model likelihood. The InfoTrad packages also estimates PIN and extends it different factorization and estimation algorithms.
- The FinancialMath package contains financial math and derivatives pricing functions as required by the actuarial exams by the Society of Actuaries and Casualty Actuarial Society ‘Financial Mathematics’ exam.
- The tidyquant package re-arranges functionality from several other key packages for use in the so-called tidyverse.
- The BCC1997 prices European options under the Bakshi, Cao anc Chen (1997) model for stochastic volatility, stochastic rates and random jumps.
- The Sim.DiffProc package provides functions to simulate and analyse multidimensional ItГґ and Stratonovitch stochastic calculus for continuous-time models.
- The BLModel package computes the posterior distribution in a Black-Litterman model from a prior distribution given by asset returns and continuous distribution of views given by an external function.
- The rpatrec package aims to recognise charting patterns in (financial) time series data.
- The PortfolioOptim can solve both small and large sample portfolio optimization.
- The estudy2 package implements most commonly used parametric and nonparametric event-study methodology tests.
- The DtD package computes the distance to default per Merton’s model.
- The PeerPerformance package analyzes performance of investments funds relative to its peers in a pairwise manner that is robust to false discoveries.
- The crseEventStudy package provides another event-study tool to analyse abnormal return in long-horizon events.
- The Task View ExtremeValue regroups a number of relevant packages.
- The packages CreditMetrics and crp.CSFP provide function for modelling credit risks.
- The mvtnorm package provides code for multivariate Normal and t-distributions.
- The Rmetrics packages fPortfolio and fExtremes also contain a number of relevant functions.
- The copula and fgac packages cover multivariate dependency structures using copula methods.
- The actuar package provides an actuarial perspective to risk management.
- The ghyp package provides generalized hyberbolic distribution functions as well as procedures for VaR, CVaR or target-return portfolio optimizations.
- The ChainLadder package provides functions for modeling insurance claim reserves; and the lifecontingencies package provides functions for financial and actuarial evaluations of life contingencies.
- The frmqa package aims to collect functions for Financial Risk Management and Quantitative Analysis.
- The ESG package can be used to model for asset projection, a scenario-based simulation approach.
- The riskSimul package provides efficient simulation procedures to estimate tail loss probabilities and conditional excess for a stock portfolios where log-returns are assumed to follow a t-copula model with generalized hyperbolic or t marginals.
- The GCPM package analyzes the default risk of credit portfolio using both analytical and simulation approaches.
- The FatTailsR package provides a family of four distributions tailored to distribution with symmetric and asymmetric fat tails.
- The Dowd package contains functions ported from the ‘MMR2’ toolbox offered in Kevin Dowd’s book “Measuring Market Risk”.
- The PortRisk package computes portfolio risk attribution.
- The NetworkRiskMeasures package implements some risk measures for financial networks such as DebtRank, Impact Susceptibility, Impact Diffusion and Impact Fluidity.
- The Risk package computes 26 financial risk measures for any continuous distribution.
- The RiskPortfolios package constructs risk-based portfolios as per the corresponding papers by Ardia et al.
- The reinsureR package models reinsurances a class Claims whose objective is to store claims and premiums, on which different treaties can be applied.
- The RM2006 package estimates conditional covariance matrix using the RiskMetrics 2006 methodology described in Zumbach (2007).
- The cvar package computes expected shortfall and value at risk for continuous distributions.
- riskParityPortfolio offers fast implementations for constructing risk-parity portfolios.
- The NMOF package provides functions, examples and data from Numerical Methods and Optimization in Finance by Manfred Gilli, Dietmar Maringer and Enrico Schumann (2011), including the different optimization heuristics such as Differential Evolution, Genetic Algorithms, Particle Swarms, and Threshold Accepting.
- The FRAPO package provides data sets and code for the book Financial Risk Modelling and Portfolio Optimization with R by Bernhard Pfaff (2013).
Data and date management