CRAN Task View: Empirical Finance

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,
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.

Time series

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.

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
ccgarch
package can estimate
(multivariate) Conditional Correlation GARCH models whereas
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.

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
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
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
maRketSim
package provides a market simulator,
initially designed around the bond market.

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
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
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
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
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.

Books

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
TFX
package provides an interface to the TrueFX (TM)
service for free streaming real-time and historical
tick-by-tick market data for interbank foreign exchange
rates at the millisecond resolution.

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
bdp,
bdh, and
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
GetHFData
package downloads and aggregates tick-by-tick
trade data for equity and derivatives markets in Brazil.

The
fmdates
package implements common date calculations
according to the ISDA schedules, and can check for business in
different locales.