25
An R tutorial on mtutual fund performance comparisons Rodolfo Vanzini — Bologna. October 8, 2015 The securities comprised in this example are (weekly time series from 5/1/2007 through 10/1/2015): JGACX JPMorgan Growth Advantage C. VFINX Vanguard 500 Index Inv. FDSSX Fidelity Stock Selec All Cp. FKCAX Franklin Flex Cap Growth Adv. SPY SPDR SP 500 ETF. TLT iShares 20+ Year Treasury Bond. DBC PowerShares DB Commodity Tracking ETF. GLD SPDR Gold Shares. SHV iShares Short Treasury Bond. setwd('C:/Users/Rudolph/Google Drive/EIMF/Financial markets') rm(list = ls()) par(mfrow = c(1,1)) require(PerformanceAnalytics) require(quantmod) require(zoo) require(Hmisc) require(xtable) tickers <- c('JGACX', 'VFINX', 'FDSSX', 'FKCAX', 'SPY', 'TLT', 'DBC', 'GLD', 'SHV') Silent to load time series (eval = FALSE): ret <- lapply(1:length(tickers), function(i){ as.xts(weeklyReturn(na.omit(getSymbols(tickers[i], auto.assign = FALSE)), subset='2007::')) } ) # do column format from list 1

An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

An R tutorial on mtutual fund performance

comparisons

Rodolfo Vanzini — Bologna.

October 8, 2015

The securities comprised in this example are (weekly time series from 5/1/2007through 10/1/2015):

JGACX JPMorgan Growth Advantage C.VFINX Vanguard 500 Index Inv.FDSSX Fidelity Stock Selec All Cp.FKCAX Franklin Flex Cap Growth Adv.SPY SPDR SP 500 ETF.TLT iShares 20+ Year Treasury Bond.DBC PowerShares DB Commodity Tracking ETF.GLD SPDR Gold Shares.SHV iShares Short Treasury Bond.

setwd('C:/Users/Rudolph/Google Drive/EIMF/Financial markets')

rm(list = ls())

par(mfrow = c(1,1))

require(PerformanceAnalytics)

require(quantmod)

require(zoo)

require(Hmisc)

require(xtable)

tickers <- c('JGACX', 'VFINX',

'FDSSX', 'FKCAX',

'SPY', 'TLT',

'DBC', 'GLD',

'SHV')

Silent to load time series (eval = FALSE):

ret <- lapply(1:length(tickers), function(i){as.xts(weeklyReturn(na.omit(getSymbols(tickers[i],

auto.assign = FALSE)),

subset='2007::'))

})

# do column format from list

1

Page 2: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

ret <- do.call(cbind, ret)

# assign ticker names to columns

names(ret) <- tickers

Read data from file (read.zoo() and as.xts())

ret <- read.zoo(file = 'demo.csv', sep = ',', header = TRUE)

ret <- as.xts(ret)

tail(ret)

## JGACX VFINX FDSSX FKCAX

## 2015-08-28 0.024105186 0.009485667 0.010793553 0.023736561

## 2015-09-04 -0.034950071 -0.033621221 -0.032323317 -0.032535490

## 2015-09-11 0.025129342 0.021301759 0.019385655 0.028604541

## 2015-09-18 0.002883922 -0.006273733 0.001170304 0.009582845

## 2015-09-25 -0.036664270 -0.013623558 -0.023962565 -0.033500838

## 2015-10-01 -0.017164179 -0.003424855 -0.009580838 -0.014442519

## SPY TLT DBC GLD

## 2015-08-28 0.008146536 -0.031885418 0.034436192 -0.021866283

## 2015-09-04 -0.033376876 0.002615226 -0.007180157 -0.011131546

## 2015-09-11 0.021911844 -0.010515170 0.001314924 -0.012373188

## 2015-09-18 -0.007367497 0.005848909 -0.014445174 0.028730170

## 2015-09-25 -0.012745731 -0.004586380 0.009327115 0.005493993

## 2015-10-01 -0.003681189 0.018676954 -0.006600660 -0.028048402

## SHV

## 2015-08-28 0.000000e+00

## 2015-09-04 1.814093e-04

## 2015-09-11 -2.720011e-04

## 2015-09-18 3.627879e-04

## 2015-09-25 1.812965e-04

## 2015-10-01 -9.066352e-05

str(ret)

## An 'xts' object on 2007-01-05/2015-10-01 containing:

## Data: num [1:457, 1:9] -0.00144 0.02312 -0.0113 0.00143 0.01712 ...

## - attr(*, "dimnames")=List of 2

## ..$ : NULL

## ..$ : chr [1:9] "JGACX" "VFINX" "FDSSX" "FKCAX" ...

## Indexed by objects of class: [Date] TZ: UTC

## xts Attributes:

## NULL

n.sec <- length(tickers)

man.col <- 1

peers.col <- c(2, 3, 4)

ind.col <- 5

Rf.col <- 9

man.len <- dim(ret)[1]

trailing12.rows = ((man.len - 11):man.len)

trailing36.rows = ((man.len - 35):man.len)

2

Page 3: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

trailing60.rows = ((man.len - 59):man.len)

For this comprehensive review of methods of performance measures on securities itmight be useful to have some color palettes to emphasize on charts certain aspects,thus we’ve created three color palettes using the set of colors available via theRColorBrewer: one (cset) has a red focus on the object of our analysis (JGACX)with shades of grey for the others (peers, benchmarks and othher securities), one(cset.1) with a qualitative range of colors for comparisons and another oner withone shade of grey (no pun intended with the popular novel!)

require(RColorBrewer)

pal <- brewer.pal(n.sec, "Greys")

pal.1 <- brewer.pal(n.sec, "Set1")

mm <- brewer.pal(3, "Set1")

cset <- c(mm[1], rev(pal[1:n.sec]))

cset.1 <- pal.1

cset.2 <- c(mm[1], rep(pal[4], n.sec - 1))

After having set up the data set let’s start by plotting some basic informationabout the time series we have using the tool set available from the rich packagePerformanceAnalytics. The focus will be on JGACX mutual fund by JP Morgan butthe first plot will use the cset.1 color palette used for comparisons.

charts.PerformanceSummary(ret[, 1:n.sec],

main ='JGACX a confronto con altri ETF e fondi',

methods = c("HistoricalVaR", "GaussianVaR", "StdDev"),

colorset = cset.1,

begin = 'first', wealth.index = TRUE, lwd = 2.0)

3

Page 4: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

Now the second plot has the red focus on JGACX mutual fund

charts.PerformanceSummary(ret[, 1:n.sec],

main ='JGACX a confronto con altri ETF e fondi',

methods = c("HistoricalVaR", "GaussianVaR", "StdDev"),

colorset = cset,

begin = 'first', wealth.index = TRUE, lwd = 2.0)

4

Page 5: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

charts.PerformanceSummary(ret[, 1:n.sec],

main ='JGACX a confronto con altri ETF e fondi',

methods = c("HistoricalVaR", "GaussianVaR", "StdDev"),

colorset = cset.2,

begin = 'first', wealth.index = TRUE, lwd = 2.0)

5

Page 6: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

charts.PerformanceSummary(ret[, c(man.col, peers.col, ind.col)],

main ='JGACX a confronto con i suoi peer',

methods = c("HistoricalVaR", "GaussianVaR", "StdDev"),

colorset = cset,

begin = 'first', wealth.index = TRUE, lwd = 2.0)

6

Page 7: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

#require(xtable)

xtable(t(table.CalendarReturns(ret[,1:n.sec])))

# kable(tab, digits = 3)

yr <- c(-0.20, 0.15)

chart.BarVaR(ret[, man.col], main = colnames(ret[ , man.col]),

methods = c("HistoricalVaR", "GaussianVaR", "StdDev"),

colorset = cset.1[man.col],

ylim = yr)

chart.BarVaR(ret[, ind.col], main =colnames(ret[ , ind.col]),

methods = c("HistoricalVaR", "GaussianVaR", "StdDev"),

colorset = cset.1[ind.col],

7

Page 8: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

2007 2008 2009 2010 2011 2012 2013 2014 2015gen 0.10 0.00 0.40 -2.50 -0.50 1.50 1.50 -0.10 -1.30feb 0.40 -1.30 -4.70 -0.20 -2.10 0.70 -1.00 1.30 -0.10

mar -1.10 0.50 5.40 1.00 3.70 1.10 1.10 -3.40 -2.60apr 1.40 1.40 0.00 -2.70 0.90 2.50 1.80 -0.70 2.30

mag 0.30 3.00 4.30 1.00 0.10 3.30 0.30 1.00 -0.40giu 0.50 -3.60 0.00 -3.50 1.60 1.40 1.80 0.20 -0.10lug -4.60 0.00 0.30 -0.30 -4.20 0.90 0.40 0.40 0.80ago 1.00 -0.80 0.30 -0.80 7.10 0.00 -1.70 1.10 2.40set 1.60 -5.50 -2.70 3.00 -2.70 -1.90 0.10 -1.70 -3.70ott 3.00 11.90 -5.30 0.50 5.40 -1.40 0.70 2.90 -1.70

nov 3.40 12.60 0.20 0.80 -5.20 1.10 0.90 0.60dic -0.10 -1.60 -1.00 -0.60 -0.50 -1.90 0.80 0.10

JGACX 5.80 16.10 -3.20 -4.20 2.90 7.40 6.80 1.60 -4.30VFINX -2.10 10.70 -4.10 -7.00 -0.20 4.30 2.20 4.90 -4.20FDSSX 0.40 14.50 -2.40 -5.50 1.00 5.50 3.50 4.40 -5.70FKCAX 4.20 15.40 -1.70 -5.90 5.20 6.10 6.00 2.30 -4.00

SPY -2.40 18.30 -1.60 -6.80 0.80 3.90 2.70 4.90 -4.30TLT 4.40 0.10 9.20 4.60 6.60 6.00 0.90 12.00 0.40DBC 10.10 10.10 -5.00 5.50 3.20 10.40 -5.00 -9.00 2.90GLD 1.60 6.40 0.70 12.70 4.00 10.70 3.20 -14.00 -8.80SHV 0.70 0.50 0.00 0.00 0.00 0.10 -0.00 0.00 -0.00

ylim = yr)

par(mfrow = c(2,2))

xr <- c(-0.25, 0.15)

chart.Boxplot(ret[ , c(man.col, peers.col, ind.col)],

main = 'Perf. a confronto',

sort.by = 'median', xlim = xr)

chart.Boxplot(ret[ trailing60.rows, c(man.col, peers.col, ind.col)],

main = 'Perf.a confronto (1 anno)',

sort.by = 'median', xlim = xr)

chart.Boxplot(ret[ trailing36.rows, c(man.col, peers.col, ind.col)],

8

Page 9: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

main = 'Perf. a confronto (6 mesi)',

sort.by = 'median', xlim = xr)

chart.Boxplot(ret[ trailing12.rows, c(man.col, peers.col, ind.col)],

main = 'Perf. a confronto (3 mesi)',

sort.by = 'median', xlim = xr)

par(mfrow = c(1,1))

9

Page 10: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

10

Page 11: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

xr <- c(0.0, 0.35)

yr <- c(-0.40, 0.12)

par(mfrow = c(2,2))

chart.RiskReturnScatter(ret[ ,c(man.col, peers.col, ind.col)],

colorset = cset.1, xlim = xr, ylim = yr,

main = 'Rend/rischio')

chart.RiskReturnScatter(ret[ trailing60.rows, c(man.col, peers.col, ind.col)],

colorset = cset.1, xlim = xr, ylim = yr,

main = 'Rend/rischio a 1 anno')

chart.RiskReturnScatter(ret[ trailing36.rows, c(man.col, peers.col, ind.col)],

colorset = cset.1, xlim = xr, ylim = yr,

main = 'Rend/rischio a 6 mesi')

chart.RiskReturnScatter(ret[ trailing12.rows, c(man.col, peers.col, ind.col)],

colorset = cset.1, xlim = xr, ylim = yr,

main = 'Rend/rischio a 3 mesi')

par(mfrow = c(1,1))

11

Page 12: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

xtable(StdDev.annualized(ret[ ,c(1:n.sec)],

scale = 52))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVAnnualized Standard Deviation 0.22 0.19 0.21 0.21 0.20 0.15 0.21 0.19 0.00

# kable(tab, digits = 4)

# textplot(tab)

xtable(SharpeRatio.annualized(ret))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVAnnualized Sharpe Ratio (Rf=0%) 0.35 0.19 0.10 0.10 0.18 0.26 -0.26 0.32 0.35

xtable(SharpeRatio.annualized(ret[ trailing60.rows, ]))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVAnnualized Sharpe Ratio (Rf=0%) 0.22 -0.04 -0.57 -0.50 -0.04 0.42 -2.65 -0.93 0.26

xtable(SharpeRatio.annualized(ret[ trailing36.rows, ]))

xtable(SharpeRatio.annualized(ret[ trailing12.rows, ]))

12

Page 13: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVAnnualized Sharpe Ratio (Rf=0%) 0.02 -0.70 -0.70 0.01 -0.70 -0.71 -1.28 -1.42 0.58

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVAnnualized Sharpe Ratio (Rf=0%) -1.40 -1.67 -2.03 -1.32 -1.69 2.76 -3.03 -1.03 0.59

par(mfrow = c(3,3))

chart.Histogram(ret[,man.col,drop=FALSE],

main = colnames(ret[,1]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,2,drop=FALSE],

main = colnames(ret[,2]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,3,drop=FALSE],

main = colnames(ret[,3]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,4,drop=FALSE],

main = colnames(ret[,4]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,5,drop=FALSE],

main = colnames(ret[,5]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,6,drop=FALSE],

main = colnames(ret[,6]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,7,drop=FALSE],

main = colnames(ret[,7]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,8,drop=FALSE],

main = colnames(ret[,8]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

chart.Histogram(ret[,9,drop=FALSE],

main = colnames(ret[,9]),

methods = c("add.risk", "add.rug"),

xlim = c(-0.18, 0.15))

par(mfrow = c(1,1))

13

Page 14: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

charts.RollingPerformance(ret[, c(man.col, peers.col, ind.col)],

colorset = cset)

charts.RollingPerformance(ret[, c(man.col, peers.col, ind.col)],

colorset = cset.1)

par(mfrow = c(4,3))

chart.RelativePerformance(ret[, c(man.col, peers.col)],

ret[, c(ind.col)],

colorset = cset,

main = 'Relative perf. SPY (5/1/2007)')

chart.RelativePerformance(ret[, c(man.col, peers.col)],

ret[, c(ind.col)],

colorset = cset.1,

main = 'Relative perf. SPY (5/1/2007)')

14

Page 15: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

chart.RelativePerformance(ret[, c(man.col, peers.col)],

ret[, c(ind.col)],

colorset = cset.2,

main = 'Relative perf. SPY (5/1/2007)')

chart.RelativePerformance(ret[trailing60.rows, c(man.col, peers.col)],

ret[trailing60.rows, c(ind.col)],

colorset = cset,

main = 'Relative perf. SPY 1 anno')

chart.RelativePerformance(ret[trailing60.rows, c(man.col, peers.col)],

ret[trailing60.rows, c(ind.col)],

colorset = cset.1,

main = 'Relative perf. SPY 1 anno')

chart.RelativePerformance(ret[trailing60.rows, c(man.col, peers.col)],

ret[trailing60.rows, c(ind.col)],

colorset = cset.2,

main = 'Relative perf. SPY 1 anno')

chart.RelativePerformance(ret[trailing36.rows, c(man.col, peers.col)],

ret[trailing36.rows, c(ind.col)],

colorset = cset,

main = 'Relative perf. SPY 6 mesi')

chart.RelativePerformance(ret[trailing36.rows, c(man.col, peers.col)],

ret[trailing36.rows, c(ind.col)],

colorset = cset.1,

main = 'Relative perf. SPY 6 mesi')

chart.RelativePerformance(ret[trailing36.rows, c(man.col, peers.col)],

ret[trailing36.rows, c(ind.col)],

colorset = cset.2,

main = 'Relative perf. SPY 6 mesi')

chart.RelativePerformance(ret[trailing12.rows, c(man.col, peers.col)],

ret[trailing12.rows, c(ind.col)],

colorset = cset,

main = 'Relative perf. SPY 3 mesi')

chart.RelativePerformance(ret[trailing12.rows, c(man.col, peers.col)],

ret[trailing12.rows, c(ind.col)],

colorset = cset.1,

main = 'Relative perf. SPY 3 mesi')

chart.RelativePerformance(ret[trailing12.rows, c(man.col, peers.col)],

ret[trailing12.rows, c(ind.col)],

colorset = cset.2,

main = 'Relative perf. SPY 3 mesi')

par(mfrow = c(1,1))

15

Page 16: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

chart.SnailTrail(ret[ ,c(man.col, peers.col, ind.col), drop=FALSE],

width=52, stepsize=12,

colorset=cset.1,

add.names="firstandlast",

rf=.02/52,

main="Trailing performance 52 sett. ogni 12 sett.")

16

Page 17: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

chart.CaptureRatios(ret[ ,1:4], ret[ ,5,drop=FALSE],

colorset = cset)

chart.CaptureRatios(ret[ ,1:4], ret[ ,5,drop=FALSE],

colorset = cset.1)

1 MPT statistics

xtable(table.CAPM(ret[ , c(man.col, peers.col)],

ret[ , ind.col, drop=FALSE],

Rf = ret[ , Rf.col, drop=FALSE]), digits = 4)

JGACX to SPY VFINX to SPY FDSSX to SPY FKCAX to SPYAlpha 0.0008 0.0000 -0.0003 -0.0002Beta 1.0469 0.9808 1.0311 0.9639

Beta+ 1.0340 0.9717 1.0317 0.9304Beta- 1.0105 0.9612 1.0086 0.9313

R-squared 0.8954 0.9877 0.9269 0.7940Annualized Alpha 0.0403 0.0005 -0.0141 -0.0100

Correlation 0.9463 0.9938 0.9628 0.8911Correlation p-value 0.0000 0.0000 0.0000 0.0000

Tracking Error 0.0708 0.0219 0.0571 0.0966Active Premium 0.0410 0.0009 -0.0149 -0.0140

Information Ratio 0.5787 0.0389 -0.2610 -0.1453Treynor Ratio 0.0708 0.0351 0.0181 0.0194

# kable(tab, digits = 4)

# textplot(tab)

xtable(table.SpecificRisk(ret[ , c(man.col, peers.col, 6:9, ind.col)],

ret[ , ind.col, drop=FALSE],

Rf = 0.0

)

17

Page 18: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

)

JGACX VFINX FDSSX FKCAX TLT DBC GLD SHV SPYSpecific Risk 0.07 0.02 0.06 0.10 0.13 0.18 0.19 0.00

Systematic Risk 0.20 0.19 0.20 0.19 -0.06 0.09 0.00 -0.00 0.20Total Risk 0.22 0.19 0.21 0.21 0.15 0.20 0.19 0.20

# kable(tab, digits = 4)

# textplot(tab)

2 Risk statistics

xtable(table.Variability(ret))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVMean Absolute deviation 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.00

Monthly Std Dev 0.03 0.03 0.03 0.03 0.03 0.02 0.03 0.03 0.00Annualized Std Dev 0.22 0.19 0.21 0.21 0.20 0.15 0.21 0.19 0.00

xtable(DownsideFrequency(ret, MAR = 0.0))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVDownside Frequency (MAR = 0%) 0.42 0.44 0.44 0.44 0.45 0.46 0.49 0.44 0.34

xtable(table.InformationRatio(ret, ret[,ind.col]))

xtable(SharpeRatio(ret[ ,c(man.col, peers.col, ind.col), drop=FALSE], Rf=0.01/52, FUN="StdDev")

)

xtable(TreynorRatio(ret[ ,c(man.col, peers.col, ind.col), drop=FALSE], ret[, ind.col, drop = FALSE], Rf=0.01/52)

)

xtable(SortinoRatio(ret[ ,c(man.col, peers.col, ind.col, 6:9), drop=FALSE], MAR=0.0)

)

xtable(table.DownsideRisk(ret[ , c(man.col, peers.col, ind.col, 6:8)],

Rf = 0.01/52,

MAR = 0.25/52)

)

# kable(tab, digits = 3)

# textplot(tab)

# title(main="Downside risk")

18

Page 19: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVTracking Error 0.01 0.00 0.01 0.01 0.00 0.04 0.03 0.04 0.03

Annualised Tracking Error 0.07 0.02 0.06 0.10 0.00 0.29 0.21 0.27 0.20Information Ratio 0.58 0.04 -0.26 -0.15 0.01 -0.42 0.10 -0.18

JGACX VFINX FDSSX FKCAX SPYStdDev Sharpe (Rf=0%, p=95%): 0.06 0.03 0.02 0.02 0.03

xtable(table.DownsideRiskRatio(ret))

kable(table.Drawdowns(ret[, man.col, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2007-11-02 2009-03-06 2011-04-29 -0.5239 183 71 1122011-07-15 2011-08-19 2012-02-03 -0.2176 30 6 242012-04-05 2012-06-01 2012-09-14 -0.1149 24 9 152015-07-24 2015-10-01 NA -0.1119 12 11 NA2014-03-14 2014-04-11 2014-07-03 -0.0992 17 5 12

kable(table.Drawdowns(ret[, ind.col, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2007-10-19 2009-03-06 2013-03-28 -0.5591 285 73 2122015-05-29 2015-10-01 NA -0.0978 20 19 NA2007-07-20 2007-08-03 2007-10-05 -0.0714 12 3 92014-09-12 2014-10-17 2014-10-31 -0.0629 8 6 22007-02-23 2007-03-16 2007-04-20 -0.0494 9 4 5

kable(table.Drawdowns(ret[, 2, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2007-10-19 2009-03-06 2013-03-15 -0.5605 283 73 2102015-05-29 2015-10-01 NA -0.0973 20 19 NA2007-07-20 2007-08-03 2007-10-05 -0.0761 12 3 92014-09-12 2014-10-17 2014-10-31 -0.0626 8 6 22013-05-24 2013-06-21 2013-07-12 -0.0479 8 5 3

kable(table.Drawdowns(ret[, 3, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2007-10-19 2009-03-06 2013-05-10 -0.5920 291 73 2182014-12-05 2015-10-01 NA -0.1663 45 44 NA2013-12-13 2013-12-13 2014-03-07 -0.0758 13 1 122014-09-12 2014-10-17 2014-11-07 -0.0663 9 6 32007-07-20 2007-08-03 2007-09-21 -0.0654 10 3 7

19

Page 20: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

JGACX VFINX FDSSX FKCAX SPYTreynor Ratio: SPY 0.06 0.03 0.01 0.01 0.02

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVSortino Ratio (MAR = 0%) 0.09 0.05 0.04 0.04 0.05 0.07 -0.03 0.08 0.07

kable(table.Drawdowns(ret[, 4, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2007-10-19 2009-03-06 2011-02-18 -0.5000 175 73 1022013-12-13 2015-01-16 NA -0.2203 96 58 NA2011-05-06 2011-08-19 2013-05-10 -0.2084 106 16 902011-02-25 2011-03-18 2011-04-21 -0.0625 9 4 52007-03-02 2007-03-02 2007-04-20 -0.0578 8 1 7

kable(table.Drawdowns(ret[, 5, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2007-10-19 2009-03-06 2013-03-28 -0.5591 285 73 2122015-05-29 2015-10-01 NA -0.0978 20 19 NA2007-07-20 2007-08-03 2007-10-05 -0.0714 12 3 92014-09-12 2014-10-17 2014-10-31 -0.0629 8 6 22007-02-23 2007-03-16 2007-04-20 -0.0494 9 4 5

kable(table.Drawdowns(ret[, 6, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2008-12-26 2011-02-04 2011-12-16 -0.2736 156 111 452012-06-08 2013-12-27 2015-01-09 -0.2190 136 82 542015-02-06 2015-06-26 NA -0.1667 36 21 NA2011-12-23 2012-03-16 2012-05-18 -0.0890 22 13 92008-03-28 2008-06-13 2008-10-03 -0.0855 28 12 16

kable(table.Drawdowns(ret[, 7, drop=FALSE]))

From Trough To Depth Length To Trough Recovery2008-07-11 2015-08-21 NA -0.6810 379 372 NA2008-03-20 2008-03-20 2008-05-09 -0.0990 8 1 72007-07-20 2007-08-17 2007-09-21 -0.0559 10 5 52007-01-05 2007-01-19 2007-02-09 -0.0544 6 3 32007-11-30 2007-11-30 2008-01-04 -0.0420 6 1 5

kable(table.Drawdowns(ret[, 8, drop=FALSE]))

20

Page 21: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLDSemi Deviation 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02Gain Deviation 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02Loss Deviation 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02

Downside Deviation (MAR=25%) 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02Downside Deviation (Rf=1%) 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02

Downside Deviation (0%) 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02Maximum Drawdown 0.52 0.56 0.59 0.50 0.56 0.27 0.68 0.43Historical VaR (95%) -0.05 -0.04 -0.04 -0.05 -0.04 -0.03 -0.05 -0.04

Historical ES (95%) -0.07 -0.06 -0.07 -0.07 -0.06 -0.04 -0.07 -0.06Modified VaR (95%) -0.05 -0.04 -0.05 -0.05 -0.04 -0.03 -0.05 -0.04

Modified ES (95%) -0.09 -0.09 -0.09 -0.09 -0.09 -0.04 -0.08 -0.06

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVMonthly downside risk 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02 0.00

Annualised downside risk 0.15 0.14 0.15 0.16 0.14 0.10 0.16 0.13 0.00Downside potential 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.00

Omega 1.19 1.12 1.08 1.08 1.12 1.12 0.94 1.16 1.21Sortino ratio 0.09 0.05 0.04 0.04 0.05 0.07 -0.03 0.08 0.07

Upside potential 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.00Upside potential ratio 0.63 0.60 0.58 0.59 0.62 0.76 0.63 0.69 0.50

Omega-sharpe ratio 0.19 0.12 0.08 0.08 0.12 0.12 -0.06 0.16 0.21

From Trough To Depth Length To Trough Recovery2011-09-09 2015-08-07 NA -0.4289 214 205 NA2008-03-20 2008-10-31 2009-09-11 -0.2773 78 33 452009-12-04 2010-02-05 2010-04-30 -0.0902 22 10 122007-04-27 2007-06-08 2007-09-07 -0.0652 20 7 132011-01-07 2011-01-28 2011-03-04 -0.0608 9 4 5

xl <- c(-0.70, 0.00)

par(mfrow=c(3,3))

chart.Drawdown(ret[, 1], colorset = cset.2[1], main = colnames(ret[,1]), ylim = xl)

chart.Drawdown(ret[, 2], colorset = cset.2[2], main = colnames(ret[,2]), ylim = xl)

chart.Drawdown(ret[, 3], colorset = cset.2[3], main = colnames(ret[,3]), ylim = xl)

chart.Drawdown(ret[, 4], colorset = cset.2[4], main = colnames(ret[,4]), ylim = xl)

chart.Drawdown(ret[, 5], colorset = cset.2[5], main = colnames(ret[,5]), ylim = xl)

chart.Drawdown(ret[, 6], colorset = cset.2[6], main = colnames(ret[,6]), ylim = xl)

chart.Drawdown(ret[, 7], colorset = cset.2[7], main = colnames(ret[,7]), ylim = xl)

chart.Drawdown(ret[, 8], colorset = cset.2[8], main = colnames(ret[,8]), ylim = xl)

chart.Drawdown(ret[, 9], colorset = cset.2[9], main = colnames(ret[,9]), ylim = xl)

par(mfrow=c(1,1))

21

Page 22: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

xl <- c(-0.70, 0.00)

par(mfrow=c(3,3))

chart.Drawdown(ret[, 1], colorset = cset.1[1], main = colnames(ret[,1]), ylim = xl)

chart.Drawdown(ret[, 2], colorset = cset.1[2], main = colnames(ret[,2]), ylim = xl)

chart.Drawdown(ret[, 3], colorset = cset.1[3], main = colnames(ret[,3]), ylim = xl)

chart.Drawdown(ret[, 4], colorset = cset.1[4], main = colnames(ret[,4]), ylim = xl)

chart.Drawdown(ret[, 5], colorset = cset.1[5], main = colnames(ret[,5]), ylim = xl)

chart.Drawdown(ret[, 6], colorset = cset.1[6], main = colnames(ret[,6]), ylim = xl)

chart.Drawdown(ret[, 7], colorset = cset.1[7], main = colnames(ret[,7]), ylim = xl)

chart.Drawdown(ret[, 8], colorset = cset.1[8], main = colnames(ret[,8]), ylim = xl)

chart.Drawdown(ret[, 9], colorset = cset.1[9], main = colnames(ret[,9]), ylim = xl)

par(mfrow=c(1,1))

22

Page 23: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

n <- table.Drawdowns(ret[,ind.col,drop=FALSE])

chart.Events(ret[,ind.col,drop=FALSE],

dates = n$Trough[1],

prior=max(na.omit(n$"To Trough")),

post=max(na.omit(n$Recovery)),

lwd=2, colorset=cset.2[1], legend.loc=NULL,

main = "Max drawdown")

23

Page 24: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

xtable(table.DrawdownsRatio(ret))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVSterling ratio 0.12 0.05 0.03 0.03 0.05 0.10 -0.07 0.11 0.02Calmar ratio 0.14 0.06 0.03 0.04 0.06 0.14 -0.08 0.14 0.31

Burke ratio 0.11 0.06 0.03 0.03 0.06 0.10 -0.07 0.11 0.15Pain index 0.10 0.12 0.15 0.11 0.12 0.12 0.43 0.15 0.00

Ulcer index 0.18 0.20 0.23 0.17 0.19 0.15 0.50 0.21 0.00Pain ratio 0.74 0.30 0.13 0.18 0.29 0.32 -0.12 0.40 0.60

Martin ratio 0.43 0.18 0.09 0.12 0.18 0.26 -0.11 0.28 0.56

It’s interesting to notice that SHV (short term Treasuries) has a pain index largerthan zero indicating that any investor must have borne limited though protractedunder water conditions.

chart.Drawdown(ret[, 9], colorset = cset.1[9], main = 'Drawdown SHV')

24

Page 25: An R tutorial on mutual fund performance comparisonsAn R tutorial on mtutual fund performance comparisons Rodolfo Vanzini | Bologna. October 8, 2015 The securities comprised in this

xtable(table.DownsideRiskRatio(ret))

JGACX VFINX FDSSX FKCAX SPY TLT DBC GLD SHVMonthly downside risk 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02 0.00

Annualised downside risk 0.15 0.14 0.15 0.16 0.14 0.10 0.16 0.13 0.00Downside potential 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.00

Omega 1.19 1.12 1.08 1.08 1.12 1.12 0.94 1.16 1.21Sortino ratio 0.09 0.05 0.04 0.04 0.05 0.07 -0.03 0.08 0.07

Upside potential 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.00Upside potential ratio 0.63 0.60 0.58 0.59 0.62 0.76 0.63 0.69 0.50

Omega-sharpe ratio 0.19 0.12 0.08 0.08 0.12 0.12 -0.06 0.16 0.21

25