PerformanceAnalytics v1.5.2


Monthly downloads



Econometric Tools for Performance and Risk Analysis

Collection of econometric functions for performance and risk analysis. 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.

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

Vignettes of PerformanceAnalytics

No Results!

Last month downloads


Type Package
Date 2018-02-28 $Date$
License GPL-2 | GPL-3
Copyright (c) 2004-2018
NeedsCompilation yes
Packaged 2018-03-01 15:16:42.16791 UTC; brian
Repository CRAN
Date/Publication 2018-03-02 17:06:04 UTC

Include our badge in your README