PerformanceAnalytics v1.5.3


Monthly downloads



Econometric Tools for Performance and Risk Analysis

Collection of econometric functions for performance and risk analysis. In addition to standard risk and performance metrics, this package aims to aid practitioners and researchers in utilizing the latest research in analysis of non-normal return streams. In general, it is most tested on return (rather than price) data on a regular scale, but most functions will work with irregular return data as well, and increasing numbers of functions will work with P&L or price data where possible.


PerformanceAnalytics: Econometric tools for performance and risk analysis.

Travis Build

PerformanceAnalytics provides an R package of econometric functions for performance and risk analysis of financial instruments or portfolios. This package aims to aid practitioners and researchers in using the latest research for analysis of both normally and non-normally distributed return streams.

We created this package to include functionality that has been appearing in the academic literature on performance analysis and risk over the past several years, but had no functional equivalent in R. In doing so, we also found it valuable to have wrappers for some functionality with good defaults and naming consistent with common usage in the finance literature.

In general, this package requires return (rather than price) data. Almost all of the functions will work with any periodicity, from annual, monthly, daily, to even minutes and seconds, either regular or irregular.

The package documentation includes sections on

  • Time Series Data
  • Performance Analysis
  • Style Analysis
  • Risk Analysis
  • Value at Risk - VaR
  • Moments and Co-moments
  • Robust Data Cleaning
  • Summary Tabular Data
  • Charts and Graphs
  • Wrapper and Utility Functions

It also includes some thoughts on work yet to be done, acknowledgments, and pointers to other literature and resources in R useful for performance and risk analysis,

Some sample data is provided in the managers dataset. It is an xts object that contains columns of monthly returns for six hypothetical asset managers (HAM1 through HAM6), the EDHEC Long-Short Equity hedge fund index, the S&P 500 total returns, and total return series for the US Treasury 10-year bond and 3-month bill. Monthly returns for all series end in December 2006 and begin at different periods starting from January 1996. That data set is used extensively in our examples and should serve as a model for formatting your data.

Functions in PerformanceAnalytics

Name Description
BetaCoMoments Functions to calculate systematic or beta co-moments of return series
BernardoLedoitRatio Bernardo and Ledoit ratio of the return distribution
BurkeRatio Burke ratio of the return distribution
CAPM.CML.slope utility functions for single factor (CAPM) CML, SML, and RiskPremium
CAPM.beta calculate single factor model (CAPM) beta
CAPM.alpha calculate single factor model (CAPM) alpha
AppraisalRatio Appraisal ratio of the return distribution
AverageDrawdown Calculates the average depth of the observed drawdowns.
ActiveReturn Active Premium or Active Return
HurstIndex calculate the Hurst Index The Hurst index can be used to measure whether returns are mean reverting, totally random, or persistent.
DRatio d ratio of the return distribution
DownsideDeviation downside risk (deviation, variance) of the return distribution
AverageLength Calculates the average length (in periods) of the observed drawdowns.
M2Sortino M squared for Sortino of the return distribution
MCA Functions for doing Moment Component Analysis (MCA) of financial time series
AdjustedSharpeRatio Adjusted Sharpe ratio of the return distribution
Omega calculate Omega for a return series
NetSelectivity Net selectivity of the return distribution
CAPM.dynamic Time-varying conditional single factor model beta
Return.Geltner calculate Geltner liquidity-adjusted return series
Frequency Frequency of the return distribution
MarketTiming Market timing models
CalmarRatio calculate a Calmar or Sterling reward/risk ratio Calmar and Sterling Ratios are yet another method of creating a risk-adjusted measure for ranking investments similar to the SharpeRatio.
Return.clean clean returns in a time series to to provide more robust risk estimates
MSquared M squared of the return distribution
InformationRatio InformationRatio = ActivePremium/TrackingError
CAPM.epsilon Regression epsilon of the return distribution
SystematicRisk Systematic risk of the return distribution
Return.convert Convert coredata content from one type of return to another
CDD Calculate Uryasev's proposed Conditional Drawdown at Risk (CDD or CDaR) measure
DrawdownPeak Drawdawn peak of the return distribution
Kappa Kappa of the return distribution
ETL calculates Expected Shortfall(ES) (or Conditional Value-at-Risk(CVaR) for univariate and component, using a variety of analytical methods.
Modigliani Modigliani-Modigliani measure
MSquaredExcess M squared excess of the return distribution
UpsidePotentialRatio calculate Upside Potential Ratio of upside performance over downside risk
AverageRecovery Calculates the average length (in periods) of the observed recovery period.
CoMoments Functions for calculating comoments of financial time series
OmegaSharpeRatio Omega-Sharpe ratio of the return distribution
Return.excess Calculates the returns of an asset in excess of the given risk free rate
CAPM.jensenAlpha Jensen's alpha of the return distribution
ProspectRatio Prospect ratio of the return distribution
EWMAMoments Functions for calculating EWMA comoments of financial time series
FamaBeta Fama beta of the return distribution
SmoothingIndex calculate Normalized Getmansky Smoothing Index
chart.ECDF Create an ECDF overlaid with a Normal CDF
PainIndex Pain index of the return distribution
MartinRatio Martin ratio of the return distribution
OmegaExcessReturn Omega excess return of the return distribution
Return.relative calculate the relative return of one asset to another
DownsideFrequency downside frequency of the return distribution
Return.annualized calculate an annualized return for comparing instruments with different length history
SharpeRatio.annualized calculate annualized Sharpe Ratio
PainRatio Pain ratio of the return distribution
Return.annualized.excess calculates an annualized excess return for comparing instruments with different length history
prices Selected Price Series Example Data
Return.calculate calculate simple or compound returns from prices
Drawdowns Find the drawdowns and drawdown levels in a timeseries.
StdDev.annualized calculate a multiperiod or annualized Standard Deviation
DrawdownDeviation Calculates a standard deviation-type statistic using individual drawdowns.
Return.centered calculate centered Returns
Level.calculate Calculate appropriate cumulative return series or asset level using xts attribute information
SpecificRisk Specific risk of the return distribution
StructuredMoments Functions for calculating structured comoments of financial time series
StdDev calculates Standard Deviation for univariate and multivariate series, also calculates component contribution to standard deviation of a portfolio
chart.CaptureRatios Chart of Capture Ratios against a benchmark
chart.VaRSensitivity show the sensitivity of Value-at-Risk or Expected Shortfall estimates
chart.Correlation correlation matrix chart
kurtosis Kurtosis
chart.TimeSeries Creates a time series chart with some extensions.
Selectivity Selectivity of the return distribution
table.SFM Single Factor Asset-Pricing Model Summary: Statistics and Stylized Facts
UpsideFrequency upside frequency of the return distribution
MeanAbsoluteDeviation Mean absolute deviation of the return distribution
SharpeRatio calculate a traditional or modified Sharpe Ratio of Return over StdDev or VaR or ES
chart.CumReturns Cumulates and graphs a set of periodic returns
chart.Histogram histogram of returns
checkData check input data type and format and coerce to the desired output type
KellyRatio calculate Kelly criterion ratio (leverage or bet size) for a strategy
Return.cumulative calculate a compounded (geometric) cumulative return
TotalRisk Total risk of the return distribution
chart.RiskReturnScatter scatter chart of returns vs risk for comparing multiple instruments
UlcerIndex calculate the Ulcer Index
Return.portfolio Calculate weighted returns for a portfolio of assets
table.AnnualizedReturns Annualized Returns Summary: Statistics and Stylized Facts
skewness Skewness
table.DrawdownsRatio Drawdowns Summary: Statistics and ratios Read returns data with different date formats
SortinoRatio calculate Sortino Ratio of performance over downside risk
TreynorRatio calculate Treynor Ratio or modified Treynor Ratio of excess return over CAPM beta
charts.RollingPerformance rolling performance chart
TrackingError Calculate Tracking Error of returns against a benchmark
table.SpecificRisk Specific risk Summary: Statistics and Stylized Facts
PerformanceAnalytics-package Econometric tools for performance and risk analysis.
chart.BarVaR Periodic returns in a bar chart with risk metric overlay
chart.Boxplot box whiskers plot wrapper
apply.rolling calculate a function over a rolling window
table.HigherMoments Higher Moments Summary: Statistics and Stylized Facts
UpDownRatios calculate metrics on up and down markets for the benchmark asset
table.CaptureRatios Calculate and display a table of capture ratio and related statistics
table.Correlation calculate correlalations of multicolumn data
table.Arbitrary wrapper function for combining arbitrary function list into a table
VolatilitySkewness Volatility and variability of the return distribution
maxDrawdown caclulate the maximum drawdown from peak equity
clean.boudt clean extreme observations in a time series to to provide more robust risk estimates
chart.Events Plots a time series with event dates aligned
sortDrawdowns order list of drawdowns from worst to best
charts.PerformanceSummary Create combined wealth index, period performance, and drawdown chart
chart.QQPlot Plot a QQ chart
apply.fromstart calculate a function over an expanding window always starting from the beginning of the series
SkewnessKurtosisRatio Skewness-Kurtosis ratio of the return distribution
table.InformationRatio Information ratio Summary: Statistics and Stylized Facts
table.Stats Returns Summary: Statistics and Stylized Facts
edhec EDHEC-Risk Hedge Fund Style Indices
chart.RollingCorrelation chart rolling correlation fo multiple assets
test_weights Sample sector weights for use by unit tests
checkSeedValue Check 'seedValue' to ensure it is compatible with coredata_content attribute of 'R' (an xts object)
table.Variability Variability Summary: Statistics and Stylized Facts
test_returns Sample sector returns for use by unit tests
chart.Bar wrapper for barchart of returns
legend internal functions for setting useful defaults for graphs
chart.Regression Takes a set of returns and relates them to a market benchmark in a scatterplot
mean.geometric calculate attributes relative to the mean of the observation series given, including geometric, stderr, LCL and UCL
chart.SnailTrail chart risk versus return over rolling time periods
table.Distributions Distributions Summary: Statistics and Stylized Facts
table.CalendarReturns Monthly and Calendar year Return table
chart.Drawdown Time series chart of drawdowns through time
chart.ACF Create ACF chart or ACF with PACF two-panel chart
chart.RelativePerformance relative performance chart between multiple return series
managers Hypothetical Alternative Asset Manager and Benchmark Data
chart.StackedBar create a stacked bar plot
table.Autocorrelation table for calculating the first six autocorrelation coefficients and significance
table.Drawdowns Worst Drawdowns Summary: Statistics and Stylized Facts
table.DownsideRiskRatio Downside Summary: Statistics and ratios
portfolio_bacon Bacon(2008) Data
chart.RollingMean chart the rolling mean return
lpm calculate a lower partial moment for a time series
chart.RollingPerformance wrapper to create a chart of rolling performance metrics in a line chart
weights Selected Portfolio Weights Data
table.DownsideRisk Downside Risk Summary: Statistics and Stylized Facts
table.ProbOutPerformance Outperformance Report of Asset vs Benchmark
table.RollingPeriods Rolling Periods Summary: Statistics and Stylized Facts
ShrinkageMoments Functions for calculating shrinkage-based comoments of financial time series
zerofill zerofill
UpsideRisk upside risk, variance and potential of the return distribution
chart.Scatter wrapper to draw scatter plot with sensible defaults
VaR calculate various Value at Risk (VaR) measures
chart.RollingQuantileRegression A wrapper to create charts of relative regression performance through time
to.period.contributions Aggregate contributions through time
replaceTabs.inner Display text information in a graphics plot.
No Results!

Vignettes of PerformanceAnalytics

No Results!

Last month downloads


Type Package
Date 2019-06-22 $Date$
License GPL-2 | GPL-3
Encoding UTF-8
Copyright (c) 2004-2019
NeedsCompilation yes
Packaged 2019-06-22 21:24:37.467506 UTC; brian
Repository CRAN
Date/Publication 2019-06-23 16:50:03 UTC

Include our badge in your README