CRAN Task View: Empirical Finance
|Contact:||Dirk.Eddelbuettel at R-project.org|
|Contributions:||Suggestions and improvements for this task view are very welcome and can be made through issues or pull requests on GitHub or via e-mail to the maintainer address. For further details see the Contributing guide.|
|Citation:||Dirk Eddelbuettel (2022). CRAN Task View: Empirical Finance. Version 2022-07-16. URL https://CRAN.R-project.org/view=Finance.|
|Installation:||The packages from this task view can be installed automatically using the ctv package. For example, |
ctv::install.views("Finance", coreOnly = TRUE) installs all the core packages or
ctv::update.views("Finance") installs all packages that are not yet installed and up-to-date. See the CRAN Task View Initiative for more details.
This CRAN Task View contains a list of packages useful for empirical work in Finance, grouped by topic.
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, Optimization, Robust, and TimeSeries Task Views.
ctv package supports these Task Views. Its functions
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, either via e-mail to the maintainer or by submitting an issue or pull request in the GitHub repository linked above. See the Contributing page in the CRAN Task Views repo for details.
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 package 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
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.
- 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 lgarch package can estimate and fit log-GARCH models. The garchx package estimate GARCH models with leverage and external covariates. The bmgarch package fits several multivariate GARCH models in a Bayesian setting.
- 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: 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 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).
- Package lmForc various in-sample, out-of-sample, pseudo-out-of-sample and benchmark linear model forecast tests.
- The Rmetrics suite of packages comprises fAssets, fBasics, fBonds, timeDate (formerly: fCalendar), fCopulae, fExtremes, fGarch, fImport, fNonlinear, 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 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 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 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 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 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 InfoTrad packages estimates PIN and extends it to 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 (archived) 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 simfinapi package provides R access to SimFin fundamental financial statement data (given an API key).
- The NFCP package models commodity prices via an n-factor term structure estimation.
- The LSMRealOptions package uses least-squares Monte Carlo to value American and Real options.
- The AssetCorr package estimates intra- and inter-cohort correlations from default data in a Vasicek credit portfolio model.
- The ichimoku package provides tools for creating and visualising Ichimoku Kinko Hyo strategies, and provides an interface to the OANDA fxTrade API for retrieving historical and live streaming price data (which requires free registration).
- The greeks package calculate sensitivities of financial option prices for European and Asian and American options in the Black Scholes model.
- The RTL (Risk Tool Library) package offers a collection of functions and metadata to complement core packages in finance and commodities, including futures expiry tables.
- The GARCHSK package estimates GARCHSK and GJRSK models allowing for time-varying volatility, skewness and kurtosis.
- The bidask package offers a novel procedure to estimate bid-ask spreads from OHLC data, and implements other reference models.
- The strand package adds a framework for discrete (share-level) simulations of investment strategies.
- The HDShOP package constructs shrinkage estimators of high-dimensional mean-variance portfolios and performs high-dimensional tests on optimality, and the DOSPortfolio package uses it to constructs dynamic optimal shrinkage estimators for the weights of the global minimum variance portfolio.
- The fixedincome package adds functions for fixed-income models, calculation, models and curves.
- The packages qrmtools and qrmdata provide tools and data for standard tasks in Quantitative Risk Management (QRM) and accompany the book of McNeil, Frey, Embrechts (2005, 2015, “Quantitative Risk Management: Concepts, Techniques, Tools”).
- The Task View ExtremeValue regroups a number of relevant packages.
- The mvtnorm package provides code for multivariate Normal and t-distributions.
- The package nvmix provides functionality for multivariate normal variance mixtures (including normal and t for non-integer degrees of freedom).
- The Rmetrics packages fPortfolio and fExtremes also contain a number of relevant functions.
- The packages copula and copulaData cover a wide range of modeling tasks for copulas.
- 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 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 monobin package performs monotonic binning of numeric risk factor in credit rating models (PD, LGD, EAD) development.
- The etrm package contains a collection of functions to perform core tasks within energy trading and risk management (ETRM).
- Package ufRisk offers multiple Value at Risk and Expected Shortfall measures from both parametric and semiparametrics models.
- 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
- The zoo and timeDate (part of Rmetrics) packages provide support for irregularly-spaced time series. The xts package extends zoo specifically for financial time series. See the TimeSeries task view for more details.
- timeDate also addresses calendar issues such as recurring holidays for a large number of financial centers, and provides code for high-frequency data sets.
- The fame package can access Fame time series databases (but also requires a Fame backend). The tis package provides time indices and time-indexed series compatible with Fame frequencies.
- The TSdbi package provides a unifying interface for several time series data base backends, and its SQL implementations provide a database table design.
- The IBrokers package provides access to the Interactive Brokers API for data access (but requires an account to access the service).
- The data.table package provides very efficient and fast access to in-memory data sets such as asset prices.
- The package highfrequency contains functionality to manage, clean and match highfrequency trades and quotes data and enables users to calculate various liquidity measures, estimate and forecast volatility, and investigate microstructure noise and intraday periodicity.
- The bizdays package compute business days if provided a list of holidays.
- The TAQMNGR package manages tick-by-tick (equity) transaction data performing ‘cleaning’, ‘aggregation’ and ‘import’ where cleaning and aggregation are performed according to Brownlees and Gallo (2006).
- The Rblpapi package offers efficient access to the Bloomberg API and allows
bds queries as well as data retrieval both in (regular time-)bars and ticks (albeit without subsecond resolution).
- The finreportr package can download reports from the SEC Edgar database, and relies on, inter alia, the XBRL package for parsing these reports.
- The GetTDData package imports Brazilian government bonds data (such as LTN, NTN-B and LFT ) from the Tesouro Direto website.
- The fmdates package implements common date calculations according to the ISDA schedules, and can check for business in different locales.
- Data from Kenneth French’s website can be downloaded with packages FFdownload and frenchdata. Individual datasets can also be downloaded with function
French in package NMOF.
|Core:||fAssets, fBasics, fBonds, fCopulae, fExtremes, fGarch, fImport, fMultivar, fNonlinear, fPortfolio, fRegression, fTrading, PerformanceAnalytics, rugarch, timeDate, timeSeries, tseries, urca, xts, zoo.|
|Regular:||actuar, AmericanCallOpt, AssetCorr, backtest, bayesGARCH, BCC1997, BenfordTests, betategarch, bidask, bizdays, BLModel, bmgarch, BurStFin, BurStMisc, CADFtest, car, ChainLadder, copula, copulaData, credule, crseEventStudy, cvar, data.table, derivmkts, dlm, DOSPortfolio, Dowd, DriftBurstHypothesis, dse, DtD, dyn, dynlm, ESG, estudy2, etrm, factorstochvol, fame, FatTailsR, FFdownload, FinancialMath, FinAsym, finreportr, fixedincome, fmdates, forecast, fracdiff, FRAPO, frenchdata, GARCHSK, garchx, GCPM, gets, GetTDData, ghyp, gmm, gogarch, greeks, GUIDE, HDShOP, highfrequency, IBrokers, ichimoku, InfoTrad, lgarch, lifecontingencies, lmForc, lmtest, longmemo, LSMonteCarlo, LSMRealOptions, markovchain, MarkowitzR, matchingMarkets, monobin, MSGARCH, mvtnorm, NetworkRiskMeasures, NFCP, nlme, NMOF, nvmix, obAnalytics, OptHedging, OptionPricing, pa, parma, pbo, PeerPerformance, PortfolioEffectHFT, PortfolioOptim, PortRisk, qrmdata, qrmtools, quantmod, ragtop, Rblpapi, Rcmdr, RcppQuantuccia, reinsureR, restimizeapi, Risk, riskParityPortfolio, RiskPortfolios, riskSimul, RM2006, rmgarch, RND, RQuantLib, RTL, sandwich, sde, SharpeR, Sim.DiffProc, simfinapi, stochvol, strand, strucchange, TAQMNGR, tidyquant, timsac, tis, TSdbi, tsDyn, tseriesChaos, TTR, tvm, ufRisk, vars, vrtest, wavelets, waveslim, wavethresh, XBRL.|