You are on page 1of 41

Using R for Hedge Fund of Funds Risk Management

R/Finance 2009: Applied Finance with R University of Illinois Chicago, April 25, 2009
Eric Zivot Professor and Gary Waterman Distinguished Scholar, Department of Economics Adjunct Professor, Departments of Finance and Statistics University of Washington

Outline
Hedge fund of funds environment Factor model risk measurement R implementation i l i in i corporate environment i Dealing with unequal data histories Some thoughts on S-PLUS and S+FinMetrics vs. R in Finance

Eric Zivot 2009

Hedge Fund of Funds Environment


HFoFs are hedge funds that invest in other hedge funds 20 to 30 portfolios of hedge funds Typical portfolio size is 30 funds Hedge fund universe is large: 5000 live funds Segmented into 10-15 distinct strategy types Hedge funds voluntarily report monthly performance to commercial databases Altvest, CISDM, HedgeFund.net, Lipper TASS, CS/Tremont, HFR HFoFs often have partial position level data on invested funds Eric Zivot 2009

Hedge Fund Universe


Live funds
Convertible Arbitrage Dedicated Short Bias Emerging Markets Equity Market Neutral Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Hedge Managed Futures Multi-Strategy Fund of Funds

Eric Zivot 2009

Characteristics of Monthly Returns


Reporting biases
Survivorship, backfill

Non-normal N l behavior b h i
Asymmetry (skewness) and fat tails (excess k t i) kurtosis)

Serial correlation
Performance smoothing, illiquid positions

Unequal histories
Eric Zivot 2009

Characteristics of Hedge Fund Data


fund1 fund2 fund3 fund4 fund5 Observations 122.0000 107.0000 135.0000 135.0000 135.0000 NAs 13.0000 28.0000 0.0000 0.0000 0.0000 Minimum -0.0842 -0.3649 -0.0519 -0.1556 -0.2900 Quartile 1 -0.0016 -0.0051 0.0020 -0.0017 -0.0021 Median 0.0058 0.0046 0.0060 0.0073 0.0049 Arithmetic Mean 0.0038 -0.0017 0.0063 0.0059 0.0021 Geometric Mean 0.0037 -0.0029 0.0062 0.0055 0.0014 Quartile 3 0.0158 0.0129 0.0127 0.0157 0.0127 Maximum 0.0311 0.0861 0.0502 0.0762 0.0877 Variance 0.0003 0.0020 0.0002 0.0008 0.0013 Stdev 0.0176 0.0443 0.0152 0.0275 0.0357 Skewness -1.7753 -5.6202 -0.8810 -2.4839 -4.9948 Kurtosis 5.2887 40.9681 3.7960 13.8201 35.8623 Rho1 0.6060 0.3820 0.3590 0.4400 0.383

Sample: p January y 1998 March 2009

Eric Zivot 2009

Factor Model Risk Measurement in HFoFs Portfolio


Quantify factor risk exposures
Equity, rates, credit, volatility, currency, commodity etc. commodity, etc

Quantify tail risk


VaR, V R ETL

Risk budgeting
Component, incremental, marginal

Stress testing and scenario analysis


Eric Zivot 2009

Commercial Products
www riskdata com www.riskdata.com www finanalytica com www.finanalytica.com

Very expensive! R is not!


Eric Zivot 2009

Factor Model: Methodology


Rit = i + i1 F1t + + ik Fkt + it , = i + i Ft + it i = 1, 1 , n; t = ti , , T Ft ~ ( F , F )

it ~ (0, 2,i )
cov( f jt , it ) = 0 for all j , i and t cov( it , jt ) = 0 for i j
Eric Zivot 2009

Practical Considerations
Many potential risk factors ( > 50) High collinearity among some factors Risk i k factors f vary across discipline/strategy di i li / Nonlinear effects Dynamic effects Time varying coefficients Common histories for factors; unequal histories for fund performance
Eric Zivot 2009

Expected Return Decomposition


E[ Rit ] = i + i1 E[ F1t ] +
i1 E [ F1t ] +

+ ik E[ Fkt ]

E Expected t d return t due d to t beta b t exposure

+ ik E [ Fkt ]

Expected return due to manager specific alpha

i = E [ Rit ] ( i1 E [ F1t ] +
Eric Zivot 2009

+ ik E [ Fkt ])

Variance Decomposition p
2 var( Rit ) = i var(Ft )i + var( it ) = i F i + ,i

systematic

specific

Variance contribution due to factor exposures

12 var(F1t ) + 22 var(F2t ) +
212 cov(F1t , F2t ) +

+ k2 var(Fkt )

Variance contribution due to covariances between factors

+ 2k 1k cov(Fk 1t , Fkt )
Eric Zivot 2009

Covariance
R t = + B Ft + t
n 1 n 1 n k k 1 n 1

var( ( Rt ) = FM = B F B + D D = diag ( , ,
2 ,1 2 ,n

Note:

cov( Rit , R jt ) = i var(Ft ) j = i F j

Eric Zivot 2009

Portfolio Analysis
w = (w1,, wn ) = portfolio p weights g
R pt = w R t = w + w BFt + w t = wi Rit = wi i + wi i Ft + wi it
i =1 i =1 i =1 i =1 n n n n

= p + p Ft + pt

Eric Zivot 2009

Portfolio Variance Decomposition


2 p = var( (R pt ) = w var( (R t )w = wB F Bw + wDw D 2 = wB F Bw p , systematic y 2 2 p = w Dw = w i ,i , specific i =1
k

2 p , systematic 2 Rp = 2 p

2 = 2 2 + covariance terms p = p, j jj , systematic p F p j =1 2 2 2 covariance terms = p p, j jj , systematic j =1


Eric Zivot 2009

Risk Budgeting: Volatility


MCR = p w = B F B w + Dw

p
B F B w

Marginal g contributions to risk

MCR systematic = MCR specific =

Dw

p
= w (BF Bw + Dw)

CR = w
n

p w

Components p to risk

1 CR = CR i = p
i =1

Eric Zivot 2009

Tail Risk Measures


Value-at-Risk (VaR)

VaR = q = F ( )
1

F = CDF of returns R
Expected Shortfall (ES)

ES = E[ R | R VaR ]

Eric Zivot 2009

Tail Risk Measures: Normal Distribution

R p ~ N ( p , ), = w FM w
2 p 2 p

VaR = p p z , z = ( )
N 1

ES = p p
N

( z )

See functions in PerformanceAnalytics


Eric Zivot 2009

Tail Risk Measures: Non Non-Normal Normal Distributions


Use Cornish-Fisher expansion p to account for asymmetry y y and fat tails
CF VaR = i i z

1 1 1 2 3 3 2 z z 1 skewi z + i 3 z ekurt i + 5 z skewi2 24 36 6

CF ES :

Formula given in Boudt, Peterson and Croux (2008) "Estimation and Decomposition of Downside Risk for Portfolios with Non-Normal Returns," Journal of Risk and implementation in PerformanceAnalytics

Eric Zivot 2009

Risk Budgeting: Tail Risk


Value-at-Risk (VaR)
VaR =
cV a R , i

i =1

VaR wi = wi

w
i =1

m VaR , i ,

VaR m VaR ,i = = E [ R i | R p = VaR ] wi cE S , i Expected Shortfall (ES) n n ES ES = wi = wi m ES , i , wi i =1 i =1 m ES , i ES = = E [ R i | R p VaR V R ] wi


Eric Zivot 2009

Risk Budgeting: Explicit Formulas


Normal distribution
See Jorian (2007) or Dowd (2002)

N Non-normal l distribution di t ib ti using i Cornish-Fisher C i h Fi h expansion


S See Boudt, B d Peterson P and d Croux C (2008) "E "Estimation i i and Decomposition of Downside Risk for Portfolios with Non Non-Normal Normal Returns, Returns " Journal of Risk and implementation in PerformanceAnalytics

Eric 9ivot 2008

Risk Budgeting: Simulation


{R }
M it t =1

= M simulated returns

Method 1: Brute Force

VaR ES mVaR ,i , mES ,i = wi wi


Method 2: Average Rit around values for which Rpt = VaR

mVaR ,i

t:Rpt =VaR

Rit , mES ,i
Eric Zivot 2009

t:Rpt VaR

Rit

R Functions for Factor Model Risk Analysis


Function factorModelCovariance factorModelRiskDecomposition normalVaR normalPortfolioVaR normalMarginalVaR normalComponentVaR normalVaRreport modifiedVaR modifiedPortfolioVaR modifiedMarginalVaR modifiedComponentVaR Function normalES normalPortfolioES normalMarginalES normalComponentES modifiedES modifiedPortfolioES modifiedESreport simulatedMarginalVaR simulatedComponentVaR simulatedMarginalES simulatedComponentES
Eric Zivot 2009

Unequal Histories
Risk factors Fund performance

F1,T , , F k ,T F1,T Ti , , F k ,T Ti F1,1 , , F k ,1


Observe full history

R1,T

R n ,T

R1,T T1 R n ,T T n

Observe partial histories


Eric Zivot 9008

X 11316 69 -0.04 1998 2000 2002 2004 2006 2008 X 15614 45 -0.06 1998 -0.02 0.02 -0.0 08 X 153684 -0.04 0.00 00 X 104314 -0.15 -0.10 -0.05 0.00 0.05 0.00 0 0.02 0.04 -0 0.3 -0.2 -0.1 0.0 0 0.1 -0.08 -0 0.04 0.00

X 29554

X 165939

Example Portfolio: Unequal Histories of Individual Funds

Eric Zivot 2009


2000 2002 2004 2006 2008

Implication of Unequal Histories


Can Cant t fit factor models to some funds
Need to create proxy factor model

St Statistics ti ti on common histories hi t i (truncated (t t d data) d t ) may be unreliable Difficult to compute non-normal tail risk measures

Eric Zivot 2009

Extract Data from Database

Analysis and Reporting Flow Process

Excel E l Spreadsheets xlsReadWrite R: Fit factor models RODBC Excel Spreadsheets RODBC R: Simulation, portfolio calculations, risk analysis R data files

Reports

Factor Model Construction


Sufficient S ffi i history? No

Yes

Fit factor model : Variable selection: leaps, MASS Collinearity diagnostics: car d dynamic i regression: i d l dynlm

Create proxy factor model from models with sufficient history

R data file

Eric Zivot 2009

Evaluation of Fitted Factor Models


Graphical diagnostics
Created plot method appropriate for time series regression. regression

Stability analysis
CUSUM etc: t strucchange t h Rolling analysis: rollapply (zoo) Time Ti varying i parameters: dlm dl

Dynamic effects
dynlm, lmtest
Eric Zivot 2009

Diagnostic Plots: Example Fund


p ,
0 .0 2 M o n th ly p e rfo rm a n c e -0 .0 6 -0 .0 4 -0 .0 2 0 .0 0

-0 .0 8

Actual Fitted 2005 2006 2007 Index 2008 2009

Eric Zivot 2008

PACF

ACF
0.6 0.8 1.0 -0.2 0.0 0.2 0.4 0.6 0 0.8 1.0

Empirica al Quantiles
-0.2 0.0 0.2 0.4

-0.04

-0.02

0.00

0. .02

-2
5

-1 0

Lag
10

norm Quantiles
1
15

Empirical fluctu uation process -1.0 0.0


-0.04

Density 0 10 20 30 40 50 60

Time Series Regression Residual diagnostics

Eric Zivot 2009


-0.5 0.0 0 0.5 1.0 0.2 0.4 Time 0.6 0.8 1.0

1.5

-0.02 Returns 0.00 0.02

OLS-based CUSUM test

X 14487 75 -0.4 -0.3 -0.2 -0.1 0.0 -0.05 0.05 0.15 0.25 -0.004 0.000 0.004

X 144874

(Intercept) (

2007

Index
2008 2009 X 144911 0.0 0.1 0.2 0.3 0

X 144887 -0.05 0.05 0 0.15

24-month rolling estimates

Eric Zivot 2009


2007

Index

2008 2009

Dealing with Unequal Histories


Estimate conditional distribution of Ri given F
Fitted factor model or proxy factor model

Estimate E ti t marginal i l distribution di t ib ti of fF


Empirical distribution, multivariate normal, copula

Derive marginal distribution of Ri from p(Ri|F) and p(F) Simulate Ri and Calculate functional of interest
Unobserved p performance, , Sharpe p ratio, , ETL etc
Eric Zivot 2009

Simulation Algorithm
Draw F 1 ,, F M by resampling from the empirical distribution of F. For each F u (u = 1, 1 , M), ) draw a value R i ,u from the estimated conditional distribution of Ri given F= F u (e.g., (e g from fitted factor model assuming normal errors) M { R i ,u }u =1 is i the h desired d i d sample l for f Ri M 5000
Eric Zivot 2009

What to do with {R } ?
M i ,u u =1

Backfill missing fund performance Compute fund and portfolio performance measures Estimate non-parametric fund and portfolio tail risk i k measures Compute non-parametric risk budgeting measures Standard errors can be computed p using ga bootstrap procedure
Eric Zivot 2009

Example: Backfilled Fund Performance

-0.05 1998

0 0.00

0.05

2000

2002 Index

2004

2006

Eric Zivot 2008

Example: Simulated portfolio distribution


9 9 %M o d V a R 9 9 %V a R

D e n sity

1 0

2 0

3 0

4 0

5 0

6 0

-0.08

-0.06

-0.04

-0.02 Returns

0.00

0.02

0.04

Eric Zivot 2009

S-PLUS S PLUS and S+FinMetrics vs R


Dealing with time series objects in R can be difficult and confusing
timeSeries, timeSeries zoo, zoo xts

Time series regression in R is incompletely i l implemented t d


Diagnostic plots, prediction

R packages give about 80% functional coverage to S+FinMetrics


Eric Zivot 2009

Some Thoughts About Using R in a C Corporate Environment i


IT doesn doesnt t want to support it Firewalls block R downloads The h world ld runs from f an Excel l spreadsheet dh Analysts with some programming experience learn R quickly Not g good for the casual user

Eric Zivot 2009

References
Boudt, , K., , B. Peterson and C. Croux ( (2008) ) "Estimation and Decomposition of Downside Risk for Portfolios with NonNormal Returns," Journal of Risk Dowd, D d K K. (2002) (2002), Measuring M i Market M k Risk Ri k, John J h Wil Wiley and d Sons Goodwo Goodworth, t , T. . and a d C. Jones Jo es ( (2007). 007). Factor-based, acto based, No Nonparametric Risk Measurement Framework for Hedge Funds and Fund-of-Funds, The European Journal of Finance. Hallerback, H ll b k J. J (2003) (2003). Decomposing D i Portfolio P f li Value-at-Risk: V l Ri k A General Analysis, The Journal of Risk 5/2. Jorian, P. (2007), Value at Risk, Third Edition, McGraw Hill
Eric Zivot 2009

References
Jiang, g, Y. ( (2009). ) Overcoming g Data Challenges g in Fund-off Funds Portfolio Management, PhD Thesis, Department of Statistics, University of Washington. Lo, L A. A (2007). (2007) Hedge H d F Funds: d An A Analytic A l i Perspective P i , Princeton. Yamai, a a , Y. .a and d T. . Yoshiba os ba ( (2002). 00 ). Comparative Co pa at ve Analyses a yses of o Expected Shortfall and Value-at-Risk: Their Estimation Error, Decomposition, and Optimization, Institute for Monetary and Economic Studies, Bank of Japan. Japan

Eric Zivot 2009

You might also like