Title: | Tools for Analyzing Time Series Data of Just Finance and Econometrics |
---|---|
Description: | Offers procedures to support financial-economic time series modelling and enhanced procedures for computing the investment performance indices of Bacon (2004) <DOI:10.1002/9781119206309>. |
Authors: | Ho Tsung-wu |
Maintainer: | Ho Tsung-wu <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.5.7 |
Built: | 2024-12-09 06:53:12 UTC |
Source: | CRAN |
The return on an investment's annualized return minus the benchmark's annualized return.
ActivePremium(Ra, Rb, scale = NA)
ActivePremium(Ra, Rb, scale = NA)
Ra |
return vector of the portfolio |
Rb |
return vector of the benchmark asset |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
Active Premium = Investment's annualized return - Benchmark's annualized return. With a view to speeding computation. I re-write the code of some ratios of the package PerformanceAnalytics, and use the same name for comparing the performance enhancing. Interested readers may compare speed improvement with the use of system.time().
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sharpe, W.F. The Sharpe Ratio,Journal of Portfolio Management, Fall 1994, 49-58.
See aslo package PerformanceAnalytics
.
Return.annualized
, InformationRatio
, TrackingError
,
data(assetReturns) assetReturns=assetReturns["2015::2018"] #short sample for fast example # Ra=assetReturns[, -29] # Rb=assetReturns[,29] #DJI # ActivePremium(Ra, Rb)
data(assetReturns) assetReturns=assetReturns["2015::2018"] #short sample for fast example # Ra=assetReturns[, -29] # Rb=assetReturns[,29] #DJI # ActivePremium(Ra, Rb)
Adjusted Sharpe ratio was introduced by Pezier and White (2006) to adjusts for skewness and kurtosis by incorporating a penalty factor for negative skewness and excess kurtosis.
AdjustedSharpeRatio(R, Rf = 0, FUN = "StdDev")
AdjustedSharpeRatio(R, Rf = 0, FUN = "StdDev")
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rf |
the risk free rate |
FUN |
one of "StdDev" or "VaR" or "ES" to use as the denominator for unadjusted Sharpe ratio, default="StdDev" |
where is the sharpe ratio with data annualized,
is the skewness and
is the kurtosis
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.99.
Pezier, Jaques and White, Anthony. 2006. The Relative Merits of Investable
Hedge Fund Indices and of Funds of Hedge Funds in Optimal Passive Portfolios.
Check https://econpapers.repec.org/paper/rdgicmadp/icma-dp2006-10.htm
See also package PerformanceAnalytics
.
data(assetReturns) AdjustedSharpeRatio(assetReturns)
data(assetReturns) AdjustedSharpeRatio(assetReturns)
Appraisal ratio is the Jensen's alpha adjusted for specific risk. The numerator is divided by specific risk instead of total risk.
AppraisalRatio(Ra, Rb, Rf = 0, method = c("appraisal", "modified", "alternative"))
AppraisalRatio(Ra, Rb, Rf = 0, method = c("appraisal", "modified", "alternative"))
Ra |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rb |
return vector of the benchmark asset |
Rf |
risk free rate, in same period as your returns |
method |
is one of "appraisal" to calculate appraisal ratio, "modified" to calculate modified Jensen's alpha or "alternative" to calculate alternative Jensen's alpha. |
Modified Jensen's alpha is Jensen's alpha divided by beta.
Alternative Jensen's alpha is Jensen's alpha divided by systematic risk.
where is the Jensen's alpha,
is the specific risk,
is the systematic risk.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.77.
See also package PerformanceAnalytics
.
data(assetReturns) Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI AppraisalRatio(Ra, Rb, method="appraisal")
data(assetReturns) Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI AppraisalRatio(Ra, Rb, method="appraisal")
To calculate Bernardo and Ledoit ratio we take the sum of the subset of returns that are above 0 and we divide it by the opposite of the sum of the subset of returns that are below 0
BernardoLedoitRatio(R)
BernardoLedoitRatio(R)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
where is the number of observations of the entire series
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.95.
See also package PerformanceAnalytics
.
data(assetReturns) BernardoLedoitRatio(R=assetReturns)
data(assetReturns) BernardoLedoitRatio(R=assetReturns)
To calculate Burke ratio we take the difference between the portfolio return and the risk free rate and we divide it by the square root of the sum of the square of the drawdowns. To calculate the modified Burke ratio we just multiply the Burke ratio by the square root of the number of datas.
BurkeRatio(R, Rf = 0, modified = FALSE)
BurkeRatio(R, Rf = 0, modified = FALSE)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rf |
the risk free rate |
modified |
a boolean to decide which ratio to calculate between Burke ratio and modified Burke ratio. |
where is the number of observations of the entire series,
is number of drawdowns,
is the portfolio return,
is the risk free rate and
the
drawdown.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.90-91.
See aslo package PerformanceAnalytics
.
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example BurkeRatio(assetReturns,Rf=0)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example BurkeRatio(assetReturns,Rf=0)
SharpeRatio
.Both the Calmar and the Sterling ratio are the ratio of annualized return over the absolute value of the maximum drawdown of an investment. The Sterling ratio adds an excess risk measure to the maximum drawdown, traditionally and defaulting to 10%.
CalmarRatio(R, scale = NA) SterlingRatio(R, scale = NA, excess = 0.1)
CalmarRatio(R, scale = NA) SterlingRatio(R, scale = NA, excess = 0.1)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
excess |
for Sterling Ratio, excess amount to add to the max drawdown, traditionally and default .1 (10%) |
It is also traditional to use a three year return series for these calculations, although the functions included here make no effort to determine the length of your series. If you want to use a subset of your series, you'll need to truncate or subset the input data to the desired length.
Many other measures have been proposed to do similar reward to risk ranking.
It is the opinion of this author that newer measures such as Sortino's
SharpeRatio
are both “better” measures, and
should be preferred to the Calmar or Sterling Ratio.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Bacon, Carl. Practical Portfolio Performance Measurement
and Attribution. Wiley. 2004.
See also package PerformanceAnalytics
.
Return.annualized
, maxDrawdown
,
data(assetReturns) R=assetReturns[, -29] # SterlingRatio(R)
data(assetReturns) R=assetReturns[, -29] # SterlingRatio(R)
The Jensen's alpha is the intercept of the regression equation in the Capital Asset Pricing Model and is in effect the exess return adjusted for systematic risk.
CAPM.jensenAlpha(Ra, Rb, Rf = 0)
CAPM.jensenAlpha(Ra, Rb, Rf = 0)
Ra |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rb |
return vector of the benchmark asset |
Rf |
risk free rate, in same period as your returns |
where is the risk free rate,
is the regression beta,
is the portfolio return and b is the benchmark return
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.72
See also package PerformanceAnalytics
.
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI CAPM.jensenAlpha(Ra, Rb)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI CAPM.jensenAlpha(Ra, Rb)
assetReturns contains DJ component stocks returns data. macrodata contains US unemployment(unrate) and year-to-year changes in three regional business cycle indices (OECD, NAFTA, and G7).
data(assetReturns) data(macrodata)
data(assetReturns) data(macrodata)
assetReturns is a time series object of package xts
.
macrodata is macroeconomic time series data.
Downside deviation, semideviation, and semivariance are measures of downside risk.
DownsideDeviation(R, MAR = 0, method = c("full", "subset"),potential = FALSE)
DownsideDeviation(R, MAR = 0, method = c("full", "subset"),potential = FALSE)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
MAR |
Minimum Acceptable Return, in the same periodicity as your returns |
method |
one of "full" or "subset", indicating whether to use the length of the full series or the length of the subset of the series below the MAR as the denominator, defaults to "full" |
potential |
if TRUE, calculate downside potential instead, default FALSE |
Downside deviation, similar to semi deviation, eliminates positive returns when calculating risk. Instead of using the mean return or zero, it uses the Minimum Acceptable Return as proposed by Sharpe (which may be the mean historical return or zero). It measures the variability of underperformance below a minimum targer rate. The downside variance is the square of the downside potential.
To calculate it, we take the subset of returns that are less than the target (or Minimum Acceptable Returns (MAR)) returns and take the differences of those to the target. We sum the squares and divide by the total number of returns to get a below-target semi-variance.
where is either the number of observations of the entire series or
the number of observations in the subset of the series falling below the
MAR.
SemiDeviation or SemiVariance is a popular alternative downside risk measure that may be used in place of standard deviation or variance. SemiDeviation and SemiVariance are implemented as a wrapper of DownsideDeviation with MAR=mean(R).
In many functions like Markowitz optimization, semideviation may be substituted directly, and the covariance matrix may be constructed from semideviation or the vector of returns below the mean rather than from variance or the full vector of returns.
In semideviation, by convention, the value of is set to the full
number of observations. In semivariance the the value of
is set to
the subset of returns below the mean. It should be noted that while this is
the correct mathematical definition of semivariance, this result doesn't
make any sense if you are also going to be using the time series of returns
below the mean or below a MAR to construct a semi-covariance matrix for
portfolio optimization.
Sortino recommends calculating downside deviation utilizing a continuous fitted distribution rather than the discrete distribution of observations. This would have significant utility, especially in cases of a small number of observations. He recommends using a lognormal distribution, or a fitted distribution based on a relevant style index, to construct the returns below the MAR to increase the confidence in the final result. Hopefully, in the future, we'll add a fitted option to this function, and would be happy to accept a contribution of this nature.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sortino, F. and Price, L. Performance Measurement in a Downside
Risk Framework. Journal of Investing. Fall 1994, 59-65.
Carl Bacon, Practical portfolio performance measurement and attribution,
second edition 2008
Plantinga, A., van der Meer, R. and Sortino, F. The Impact of Downside Risk
on Risk-Adjusted Performance of Mutual Funds in the Euronext Markets. July
19, 2001. Available at SSRN:https://papers.ssrn.com/sol3/papers.cfm?abstract_id=277352
see especially end note 10 https://en.wikipedia.org/wiki/Semivariance.
See also package PerformanceAnalytics
.
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example R=assetReturns[, -29] DownsideDeviation(R, MAR = 0)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example R=assetReturns[, -29] DownsideDeviation(R, MAR = 0)
The d ratio is similar to the Bernado Ledoit ratio but inverted and taking into account the frequency of positive and negative returns.
DRatio(R)
DRatio(R)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
It has values between zero and infinity. It can be used to rank the performance of portfolios. The lower the d ratio the better the performance, a value of zero indicating there are no returns less than zero and a value of infinity indicating there are no returns greater than zero.
where is the number of observations of the entire series,
is the number of observations less than zero,
is the number of observations greater than zero
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.95
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] DRatio(R)
data(assetReturns) R=assetReturns[, -29] DRatio(R)
Drawdawn peak is for each return its drawdown since the previous peak
DrawdownPeak(R)
DrawdownPeak(R)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
data(assetReturns) R=assetReturns[, -29] # Not run # DrawdownPeak(R)
data(assetReturns) R=assetReturns[, -29] # Not run # DrawdownPeak(R)
durbinH test the serial correlation of a dynamic regression, namely, a time series regression with AR(1) terms. It modifies Durbin-Watson statictic.
durbinH(model,Ly.label="ar1")
durbinH(model,Ly.label="ar1")
model |
Estimation result object by, for example, dynlm or arima |
Ly.label |
Label of AR(1) dependent variable |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
data(macrodata) y=ts(macrodata[,"OECD"],start=c(1961,1),freq=12) #OECD business cycle index out1=dynlm::dynlm(y~L(y,1)+season(y)+trend(y)) durbinH(out1,Ly.label="L(y, 1)")
data(macrodata) y=ts(macrodata[,"OECD"],start=c(1961,1),freq=12) #OECD business cycle index out1=dynlm::dynlm(y~L(y,1)+season(y)+trend(y)) durbinH(out1,Ly.label="L(y, 1)")
It downloads effective exchange rates from Bank of International Settlement.
getBIS(sheet="Real", type="broad")
getBIS(sheet="Real", type="broad")
sheet |
The name of spreedsheet of effective exchange rates (EER)of BIS, it has two options: "Real" and "Nominal", the default is "Real" for REER. |
type |
The type of EER, it has two types: "broad" and "narrow". The default is "broad". |
This function connects with <"https://www.bis.org/statistics/eer/"> and downloads the specified data. The rownames of downloaded data embeds the timestamp already, which can be directly transformed into time series via, as.timeSeries.
data |
The data object. |
country.info |
The country information with abbreviated symbol. |
data.info |
The information about effective exchange rates. |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
#To save time, the example below is commented. #output=getBIS(sheet=c("Nominal","Real")[1], type=c("broad","narrow")[1]) #output$data #output$data.info #output$country.info
#To save time, the example below is commented. #output=getBIS(sheet=c("Nominal","Real")[1], type=c("broad","narrow")[1]) #output$data #output$data.info #output$country.info
It downloads financial and economic time series data from the Fed.
getFed(var.name="UNRATE", from="1900-01-01",end=Sys.Date(), do.plot=TRUE)
getFed(var.name="UNRATE", from="1900-01-01",end=Sys.Date(), do.plot=TRUE)
var.name |
The name of variable as used by <"https://fred.stlouisfed.org">. For example, "UNRATE" denotes unemployment rate, "CPIAUCSL" is monthly consumer price index, "GDP" is Gross domestic product, and "ICSA" is the initial claim seasonally adjusted. User please check with the web for symbol. |
from |
The starting date, the default is 1900-01-01 to ensure the very beginning. |
end |
The ending date of data retrieved, the default is Sys.Date(). |
do.plot |
Whether to plot the retrieved data, the default is TRUE. Please set this value to be FALSE to avoid too many plotting, if you want to loop more downloads. It applies functionseriesPlot() from package fBasics. |
This function connects with <"https://fred.stlouisfed.org"> and downloads the specified market data. The rownames of downloaded data is embedded by the timestamp already.
data |
The data retrieved. |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
#To save time, the example below is commented. #getFed(var.name="UNRATE")$data
#To save time, the example below is commented. #getFed(var.name="UNRATE")$data
It downloads seven factors data used for asset pricing analysis from the data library of Dr. Kenneth R. French at Dartmouth College.
#To save time, the example below is commented. #getFrench.Factors(filename="F-F_Research_Data_5_Factors_2x3")
#To save time, the example below is commented. #getFrench.Factors(filename="F-F_Research_Data_5_Factors_2x3")
filename |
The name of data file as listed in <"http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html">, which is an important database for asset pricing literature, this function supports seven factor files: |
This function connects with <"http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html"> and downloads the specified factors data. Sometimes, the datafile contains multiple data tables, hence the code returns a list.
ff.factor |
The data retrieved and arranged. |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
getFrench.Factors(filename="F-F_Research_Data_Factors")
getFrench.Factors(filename="F-F_Research_Data_Factors")
It downloads 24 factors data used for asset pricing analysis from the data library of Dr. Kenneth R. French at Dartmouth College.
getFrench.Portfolios(filename="Portfolios_Formed_on_ME")
getFrench.Portfolios(filename="Portfolios_Formed_on_ME")
filename |
The name of portfolio data file as listed in (http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html), the default is "Portfolios_Formed_on_ME". So far, this function supports retrieving 24 portfolio data files: |
This function connects with <"http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html"> and downloads the specified portfolio data constructed by factors. Currently, we support on retriving and arranging 24 portfolio datasets. Sometimes, the datafile contains multiple data tables, hence the code returns a list. Since the csv spreedsheet on the web is not structured data table, it does not only contain irregular headings, but also 7, or more, data tablesr; and the trivial portfolio data tables labelled by "Portfolio Formed by ..." are omitted. Check the "table.names" of output object.
data |
The data retrieved and arranged. |
table.names |
The names of data table. |
file.name |
The file name of portfolio data. |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
#To save time, the example below is commented. #output=getFrench.Portfolios(filename="5_Industry_Portfolios") #output$file.name #dim(output$data[[1]]) #output$data #output$table.names
#To save time, the example below is commented. #output=getFrench.Portfolios(filename="5_Industry_Portfolios") #output$file.name #dim(output$data[[1]]) #output$data #output$table.names
The Active Premium divided by the Tracking Error.
InformationRatio(Ra, Rb, scale = NA)
InformationRatio(Ra, Rb, scale = NA)
Ra |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rb |
return vector of the benchmark asset |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
InformationRatio = ActivePremium/TrackingError
This relates the degree to which an investment has beaten the benchmark to the consistency with which the investment has beaten the benchmark.
William Sharpe now recommends InformationRatio
preferentially
to the original SharpeRatio
.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sharpe, W.F. The Sharpe Ratio,Journal of Portfolio
Management,Fall 1994, 49-58.
See also package PerformanceAnalytics
.
TrackingError
ActivePremium
SharpeRatio
data(assetReturns) Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI InformationRatio(Ra, Rb)
data(assetReturns) Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI InformationRatio(Ra, Rb)
Kelly criterion ratio (leverage or bet size) for a strategy.
KellyRatio(R, Rf = 0)
KellyRatio(R, Rf = 0)
R |
a vector of returns to perform a mean over |
Rf |
risk free rate, in same period as your returns |
The Kelly Criterion was identified by Bell Labs scientist John Kelly, and applied to blackjack and stock strategy sizing by Ed Thorpe.
The Kelly ratio can be simply stated as: “bet size is the ratio of edge over odds.” Mathematically, you are maximizing log-utility. As such, the Kelly criterion is equal to the expected excess return of the strategy divided by the expected variance of the excess return, or
As a performance metric, the Kelly Ratio is calculated retrospectively on a particular investment as a measure of the edge that investment has over the risk free rate. It may be use as a stack ranking method to compare investments in a manner similar to the various ratios related to the Sharpe ratio.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Thorp, Edward O. (1997; revised 1998). The Kelly Criterion in
Blackjack, Sports Betting, and the Stock Market.
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] KellyRatio(R, Rf=0)
data(assetReturns) R=assetReturns[, -29] KellyRatio(R, Rf=0)
M squared for Sortino is a M^2 calculated for Downside risk instead of Total Risk
M2Sortino(Ra, Rb, MAR = 0)
M2Sortino(Ra, Rb, MAR = 0)
Ra |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset return |
Rb |
return vector of the benchmark asset |
MAR |
the minimum acceptable return |
where is MSquared for Sortino,
is the annualised portfolio return,
is the benchmark annualised downside risk and
is the portfolio
annualised downside risk
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.102-103
See aslo package PerformanceAnalytics
.
data(assetReturns) Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI M2Sortino(Ra, Rb, MAR=0)
data(assetReturns) Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI M2Sortino(Ra, Rb, MAR=0)
To calculate Martin ratio we divide the difference of the portfolio return and the risk free rate by the Ulcer index
MartinRatio(R, Rf = 0)
MartinRatio(R, Rf = 0)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rf |
risk free rate, in same period as your returns |
where is the annualized portfolio return,
is the risk free
rate,
is the number of observations of the entire series,
is
the drawdown since previous peak in period i
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.91
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] # Not run # MartinRatio(R)
data(assetReturns) R=assetReturns[, -29] # Not run # MartinRatio(R)
To find the maximum drawdown in a return series, we need to first calculate the cumulative returns and the maximum cumulative return to that point. Any time the cumulative returns dips below the maximum cumulative returns, it's a drawdown. Drawdowns are measured as a percentage of that maximum cumulative return, in effect, measured from peak equity.
maxDrawdown(R, geometric = TRUE, invert = TRUE)
maxDrawdown(R, geometric = TRUE, invert = TRUE)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
geometric |
utilize geometric chaining (TRUE) or simple/arithmetic chaining (FALSE) to aggregate returns, default TRUE |
invert |
TRUE/FALSE whether to invert the drawdown measure. see Details. |
The option to invert
the measure should appease both academics and
practitioners. The default option invert=TRUE
will provide the
drawdown as a positive number. This should be useful for optimization
(which usually seeks to minimize a value), and for tables (where having
negative signs in front of every number may be considered clutter).
Practitioners will argue that drawdowns denote losses, and should be
internally consistent with the quantile (a negative number), for which
invert=FALSE
will provide the value they expect. Individually,
different preferences may apply for clarity and compactness. As such, we
provide the option, but make no value judgment on which approach is
preferable.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Bacon, C. Practical Portfolio Performance Measurement and
Attribution. Wiley. 2004. p. 88
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] maxDrawdown(R)
data(assetReturns) R=assetReturns[, -29] maxDrawdown(R)
To calculate Mean absolute deviation we take the sum of the absolute value of the difference between the returns and the mean of the returns and we divide it by the number of returns.
MeanAbsoluteDeviation(R)
MeanAbsoluteDeviation(R)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
where is the number of observations of the entire series,
is the
return in month i and
is the mean return
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.62.
See also package PerformanceAnalytics
.
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example R=assetReturns[, -29] MeanAbsoluteDeviation(R)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example R=assetReturns[, -29] MeanAbsoluteDeviation(R)
The Omega-Sharpe ratio is a conversion of the omega ratio to a ranking statistic in familiar form to the Sharpe ratio.
OmegaSharpeRatio(R, MAR = 0)
OmegaSharpeRatio(R, MAR = 0)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
MAR |
Minimum Acceptable Return, in the same periodicity as your returns |
To calculate the Omega-Sharpe ration we subtract the target (or Minimum Acceptable Returns (MAR)) return from the portfolio return and we divide it by the opposite of the Downside Deviation.
where is the number of observations of the entire series
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008, p.95
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] OmegaSharpeRatio(R)
data(assetReturns) R=assetReturns[, -29] OmegaSharpeRatio(R)
The pain index is the mean value of the drawdowns over the entire analysis period. The measure is similar to the Ulcer index except that the drawdowns are not squared. Also, it's different than the average drawdown, in that the numerator is the total number of observations rather than the number of drawdowns.
PainIndex(R)
PainIndex(R)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Visually, the pain index is the area of the region that is enclosed by the horizontal line at zero percent and the drawdown line in the Drawdown chart.
where is the number of observations of the entire series,
is
the drawdown since previous peak in period i
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.89, Becker, Thomas (2006) Zephyr Associates
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] # Not run # PainIndex(R)
data(assetReturns) R=assetReturns[, -29] # Not run # PainIndex(R)
To calculate Pain ratio we divide the difference of the portfolio return and the risk free rate by the Pain index
PainRatio(R, Rf = 0)
PainRatio(R, Rf = 0)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rf |
risk free rate, in same period as your returns |
where is the annualized portfolio return,
is the risk free
rate,
is the number of observations of the entire series,
is
the drawdown since previous peak in period i
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.91
See also package PerformanceAnalytics
.
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example R=assetReturns[, -29] PainRatio(R)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example R=assetReturns[, -29] PainRatio(R)
Prospect ratio is a ratio used to penalise loss since most people feel loss greater than gain
ProspectRatio(R, MAR)
ProspectRatio(R, MAR)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
MAR |
the minimum acceptable return |
where is the number of observations of the entire series, MAR is the minimum acceptable return and
is the downside risk
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.100
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] ProspectRatio(R, MAR=0)
data(assetReturns) R=assetReturns[, -29] ProspectRatio(R, MAR=0)
An average annualized return is convenient for comparing returns.
Return.annualized(R, scale = NA, geometric = TRUE)
Return.annualized(R, scale = NA, geometric = TRUE)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
geometric |
utilize geometric chaining (TRUE) or simple/arithmetic chaining (FALSE) to aggregate returns, default TRUE |
Annualized returns are useful for comparing two assets. To do so, you must scale your observations to an annual scale by raising the compound return to the number of periods in a year, and taking the root to the number of total observations:
where scale is the number of periods in a year, and n is the total number of periods for which you have observations.
For simple returns (geometric=FALSE), the formula is:
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Bacon, Carl. Practical Portfolio Performance Measurement
and Attribution. Wiley. 2004. p. 6
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] Return.annualized(R)
data(assetReturns) R=assetReturns[, -29] Return.annualized(R)
The Sharpe ratio is simply the return per unit of risk (represented by variability). In the classic case, the unit of risk is the standard deviation of the returns.
SharpeRatio(R, Rf = 0, alpha = 0.05, FUN="StdDev",annualize=FALSE)
SharpeRatio(R, Rf = 0, alpha = 0.05, FUN="StdDev",annualize=FALSE)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rf |
risk free rate, in same period as your returns |
alpha |
Tail probability for VaR or ES, default alpha=.05 |
FUN |
one of "StdDev" or "VaR" or "ES" to use as the denominator |
annualize |
if TRUE, annualize the measure, default FALSE |
William Sharpe now recommends InformationRatio
preferentially
to the original Sharpe Ratio.
The higher the Sharpe ratio, the better the combined performance of "risk" and return.
As noted, the traditional Sharpe Ratio is a risk-adjusted measure of return that uses standard deviation to represent risk.
A number of papers now recommend using a "modified Sharpe" ratio using a Modified Cornish-Fisher VaR or CVaR/Expected Shortfall as the measure of Risk.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sharpe, W.F. The Sharpe Ratio,Journal of Portfolio
Management,Fall 1994, 49-58.
Laurent Favre and Jose-Antonio Galeano. Mean-Modified Value-at-Risk
Optimization with Hedge Funds. Journal of Alternative Investment, Fall 2002,
v 5.
See also package PerformanceAnalytics.
SharpeRatio.annualized
InformationRatio
TrackingError
ActivePremium
SortinoRatio
data(assetReturns) R=assetReturns[, -29] SharpeRatio(R)
data(assetReturns) R=assetReturns[, -29] SharpeRatio(R)
The Sharpe Ratio is a risk-adjusted measure of return that uses standard deviation to represent risk.
SharpeRatio.annualized(R, Rf = 0, alpha=0.05,scale = NA, geometric = TRUE, FUN = "StdDev")
SharpeRatio.annualized(R, Rf = 0, alpha=0.05,scale = NA, geometric = TRUE, FUN = "StdDev")
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rf |
risk free rate, in same period as your returns |
alpha |
Tail probability for VaR or ES, default alpha=.05 |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
geometric |
utilize geometric chaining (TRUE) or simple/arithmetic chaining (FALSE) to aggregate returns,default TRUE |
FUN |
one of "StdDev" or "VaR" or "ES" to use as the denominator, default="StdDev" |
The Sharpe ratio is simply the return per unit of risk (represented by variance). The higher the Sharpe ratio, the better the combined performance of "risk" and return.
This function annualizes the number based on the scale parameter.
Using an annualized Sharpe Ratio is useful for comparison of multiple return streams. The annualized Sharpe ratio is computed by dividing the annualized mean monthly excess return by the annualized monthly standard deviation of excess return.
William Sharpe now recommends Information Ratio preferentially to the original Sharpe Ratio.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sharpe, W.F. The Sharpe Ratio,Journal of Portfolio
Management,Fall 1994, 49-58.
See also package PerformanceAnalytics
.
SharpeRatio
InformationRatio
TrackingError
ActivePremium
SortinoRatio
data(assetReturns) R=assetReturns[, -29] SharpeRatio.annualized(R)
data(assetReturns) R=assetReturns[, -29] SharpeRatio.annualized(R)
Skewness-Kurtosis ratio is the division of Skewness by Kurtosis.
SkewnessKurtosisRatio(R)
SkewnessKurtosisRatio(R)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
It is used in conjunction with the Sharpe ratio to rank portfolios. The higher the rate the better.
where is the skewness and
is the Kurtosis
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.100
See also package PerformanceAnalytics
.
data(assetReturns) R=assetReturns[, -29] SkewnessKurtosisRatio(R)
data(assetReturns) R=assetReturns[, -29] SkewnessKurtosisRatio(R)
Sortino proposed an improvement on the Sharpe Ratio to better account for skill and excess performance by using only downside semivariance as the measure of risk.
SortinoRatio(R, MAR = 0)
SortinoRatio(R, MAR = 0)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
MAR |
Minimum Acceptable Return, in the same periodicity as your returns |
Sortino contends that risk should be measured in terms of not meeting the investment goal. This gives rise to the notion of “Minimum Acceptable Return” or MAR. All of Sortino's proposed measures include the MAR, and are more sensitive to downside or extreme risks than measures that use volatility(standard deviation of returns) as the measure of risk.
Choosing the MAR carefully is very important, especially when comparing disparate investment choices. If the MAR is too low, it will not adequately capture the risks that concern the investor, and if the MAR is too high, it will unfavorably portray what may otherwise be a sound investment. When comparing multiple investments, some papers recommend using the risk free rate as the MAR. Practitioners may wish to choose one MAR for consistency, several standardized MAR values for reporting a range of scenarios, or a MAR customized to the objective of the investor.
where
is the
DownsideDeviation
.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sortino, F. and Price, L. Performance Measurement in a Downside
Risk Framework. Journal of Investing. Fall 1994, 59-65.
See also package PerformanceAnalytics
.
SharpeRatio
DownsideDeviation
InformationRatio
data(assetReturns) R=assetReturns[, -29] SortinoRatio(R)
data(assetReturns) R=assetReturns[, -29] SortinoRatio(R)
Table of Annualized Return, Annualized Std Dev, and Annualized Sharpe
table.AnnualizedReturns(R, scale = NA, Rf = 0, geometric = TRUE, digits = 4)
table.AnnualizedReturns(R, scale = NA, Rf = 0, geometric = TRUE, digits = 4)
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
Rf |
risk free rate, in same period as your returns |
geometric |
utilize geometric chaining (TRUE) or simple/arithmetic chaining (FALSE) to aggregate returns, default TRUE |
digits |
number of digits to round results to |
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Return.annualized
SharpeRatio.annualized
data(assetReturns) Ra=assetReturns[, -29] table.AnnualizedReturns(R=Ra)
data(assetReturns) Ra=assetReturns[, -29] table.AnnualizedReturns(R=Ra)
A measure of the unexplained portion of performance relative to a benchmark.
TrackingError(Ra, Rb, scale = NA)
TrackingError(Ra, Rb, scale = NA)
Ra |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rb |
return vector of the benchmark asset |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
Tracking error is calculated by taking the square root of the average of the squared deviations between the investment's returns and the benchmark's returns, then multiplying the result by the square root of the scale of the returns.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Sharpe, W.F. The Sharpe Ratio,Journal of Portfolio
Management,Fall 1994, 49-58.
See also package PerformanceAnalytics
.
InformationRatio
TrackingError
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI TrackingError(Ra, Rb)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI TrackingError(Ra, Rb)
The Treynor ratio is similar to the Sharpe Ratio, except it uses beta as the volatility measure (to divide the investment's excess return over the beta).
TreynorRatio(Ra, Rb, Rf = 0, scale = NA, modified = FALSE)
TreynorRatio(Ra, Rb, Rf = 0, scale = NA, modified = FALSE)
Ra |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
Rb |
return vector of the benchmark asset |
Rf |
risk free rate, in same period as your returns |
scale |
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4) |
modified |
a boolean to decide whether to return the Treynor ratio or Modified Treynor ratio |
To calculate modified Treynor ratio, we divide the numerator by the systematic risk instead of the beta.
Equation:
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
https://en.wikipedia.org/wiki/Treynor_ratio,
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.77
See also package PerformanceAnalytics
.
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI TreynorRatio(Ra, Rb)
data(assetReturns) assetReturns=assetReturns["2011::2018"] #short sample for fast example Ra=assetReturns[, -29] Rb=assetReturns[,29] #DJI TreynorRatio(Ra, Rb)
Developed by Peter G. Martin in 1987 (Martin and McCann, 1987) and named for the worry caused to the portfolio manager or investor. This is similar to drawdown deviation except that the impact of the duration of drawdowns is incorporated by selecting the negative return for each period below the previous peak or high water mark. The impact of long, deep drawdowns will have significant impact because the underperformance since the last peak is squared.
UlcerIndex(R)
UlcerIndex(R)
R |
a vector, matrix, data frame, timeSeries or zoo object of asset returns |
UI = sqrt(sum[i=1,2,...,n](D'_i^2/n)) where D'_i = drawdown since previous peak in period i
DETAILS: This approach is sensitive to the frequency of the time periods involved and penalizes managers that take time to recover to previous highs.
REFERENCES: Martin, P. and McCann, B. (1989) The investor's Guide to Fidelity Funds: Winning Strategies for Mutual Fund Investors. John Wiley & Sons, Inc.
See also package PerformanceAnalytics
.
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
data(assetReturns) R=assetReturns[, -29] maxDrawdown(R)
data(assetReturns) R=assetReturns[, -29] maxDrawdown(R)
Volatility skewness is a similar measure to omega but using the second partial moment. It's the ratio of the upside variance compared to the downside variance. Variability skewness is the ratio of the upside risk compared to the downside risk.
VolatilitySkewness(R, MAR = 0, stat = c("volatility", "variability"))
VolatilitySkewness(R, MAR = 0, stat = c("volatility", "variability"))
R |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
MAR |
Minimum Acceptable Return, in the same periodicity as your returns |
stat |
one of "volatility", "variability" indicating whether to return the volatility skewness or the variability skweness |
where is the Upside risk and
is the Downside Risk
Ho Tsung-wu <[email protected]>, College of Management, National Taiwan Normal University.
Carl Bacon, Practical portfolio performance measurement
and attribution, second edition 2008 p.97-98.
See also package PerformanceAnalytics.
data(assetReturns) R=assetReturns[, -29] VolatilitySkewness(R, MAR=0, stat="volatility")
data(assetReturns) R=assetReturns[, -29] VolatilitySkewness(R, MAR=0, stat="volatility")