R Econometric tools for performance and risk analysis
Post on: 8 Апрель, 2015 No Comment
Time Series Data
Not all, but many of the measures in this package require time series data. PerformanceAnalytics uses the xts package for managing time series data for several reasons. Besides being fast and efficient, xts includes functions that test the data for periodicity and draw attractive and readable time-based axes on charts. Another benefit is that xts provides compatability with Rmetrics’ timeSeries. zoo and other time series classes, such that PerformanceAnalytics functions that return a time series will return the results in the same format as the object that was passed in. Jeff Ryan and Josh Ulrich, the authors of xts. have been extraordinarily helpful to the development of PerformanceAnalytics and we are very greatful for their contributions to the community. The xts package extends the excellent zoo package written by Achim Zeileis and Gabor Grothendieck. zoo provides more general time series support, whereas xts provides functionality that is specifically aimed at users in finance.
Users can easily load returns data as time series for analysis with PerformanceAnalytics by using the Return.read function. The Return.read function loads csv files of returns data where the data is organized as dates in the first column and the returns for the period in subsequent columns. See read.zoo and as.xts if more flexibility is needed.
The functions described below assume that input data is organized with asset returns in columns and dates represented in rows. All of the metrics in PerformanceAnalytics are calculated by column and return values for each column in the results. This is the default arrangement of time series data in xts.
See function Return.calculate for calculating returns from prices, and be aware that the aggregate function has methods for tseries and zoo timeseries data classes to rationally coerce irregular data into regular data of the correct periodicity.
Performance Analysis
Performance measurement is the first step down a longer road. When discussing performance at an abstract level, terms such as return and risk are deliberately vague because they help to disguise some (usually unnecessary) complexity. Scratch the surface to answer more complicated questions, and that complexity is necessarily uncovered again. Indeed, the literature around the subject of performance analysis seems to have exploded with the popularity of alternative assets such as hedge funds, managed futures, commodities, and structured products. Simpler tools that seemed appropriate in a relative investment world seem inappropriate for an absolute return world. Risk measurement, which is nearly inseparable from performance assessment, has been on a long march to become multi-dimensional and multi-moment while trying to answer the question: How much could I lose? Portfolio construction and risk budgeting are two sides of the same coin: How do I maximize my expected gain and avoid going broke? But before we can approach those questions we first have to ask: Is this something I might want in my portfolio?
With the the increasing availability of complicated alternative investment strategies to both retail and institutional investors, and the broad availability of financial data, an engaging debate about performance analysis and evaluation is as important as ever. There won’t be one right answer delivered in these metrics and charts. What there will be is an accretion of evidence, organized to assist a decision maker in answering a specific question that is pertinent to the decision at hand. Using such tools to uncover information and ask better questions will, in turn, create a more informed investor.
Performance measurement starts with returns. Traders may object, complaining that You can’t eat returns, and will prefer to look for numbers with currency signs. To some extent, they have a point — the normalization inherent in calculating returns can be deceiving. Most of the recent work in performance analysis, however, is focused on returns rather than prices and sometimes called returns-based analysis or RBA. This price per unit of investment standardization is important for two reasons — first, it helps the decision maker to compare opportunities, and second, it has some useful statistical qualities. As a result, the PerformanceAnalytics library focuses on returns. See Return.calculate for converting net asset values or prices into returns, either discrete or continuous. Many papers and theories refer to excess returns: we implement a simple function for aligning time series and calculating excess returns in Return.excess.
We provide two functions to calculate weighted returns for a portfolio of assets. If you have a single weighting vector, or want the equal weighted portfolio, use Return.portfolio. If you have a portfolio that is periodically rebalanced, and multiple time periods with different weights, use Return.rebalancing. Both functions will subset the return series to only include returns for assets for which weight is provided.
Returns and risk may be annualized as a way to simplify comparison over longer time periods. Although it requires a bit of estimating, such aggregation is popular because it offers a reference point for easy comparison. Examples are in Return.annualized. sd.annualized. and SharpeRatio.annualized.
Basic measures of performance tend to treat returns as independent observations. In this case, the entirety of R’s base is applicable to such analysis. Some basic statistics we have collected in table.MonthlyReturns include: