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 in corporate environment Dealing with unequal data histories Some thoughts on S-PLUS and S+FinMetrics vs. R in Finance
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
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
Characteristics of Monthly Returns Reporting biases Survivorship, backfill Non-normal lbehavior Asymmetry (skewness) and fat tails (excess kurtosis) Serial correlation Performance smoothing, illiquid positions Unequal histories
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: January 1998 March 2009
Factor Model Risk Measurement in HFoFs Portfolio Quantify factor risk exposures Equity, rates, credit, volatility, currency, commodity, etc. Quantify tail risk VRETL VaR, Risk budgeting Component, incremental, marginal Stress testing and scenario analysis
Commercial Products www.riskdata.com www.finanalytica.com com Very expensive! R is not!
Factor Model: Methodology R F F it = αi + βi 1 1 t + + β ε ik kt + it, = αi + β if ε t + it i = 1,, n; t = t,, T F ~ ( μ, Σ ) t ε 2 ~ (0, σ it ε, i ) cov( f, ε ) = 0 for all j, i and t jt it cov( ε, ε it jt ) = 0 for i j F F i
Practical Considerations Many potential risk factors ( > 50) High collinearity among some factors Risk ikfactors vary across discipline/strategy ili Nonlinear effects Dynamic effects Time varying coefficients Common histories for factors; unequal histories for fund performance
Expected Return Decomposition E[ R ] = α + β E [ F ] + + β E [ F ] [ it i i1 1t ik kt Expected return due to beta exposure β i E F ] + + β i 1 [ 1 t ik E[ F kt ] Expected return due to manager specific alpha α = E R ] ( β E[ F ] + + i [ it i1 1t β ik E[ Fkt ])
Variance Decomposition var( R ) var( ) var( ε ) σ 2 it = βi Ft βi + εit = βi ΣF βi + σε, i systematic specific Variance contribution due to factor exposures 2 2 β var( F ) + β var( F ) + + β var( F 2 1 1t 2 2t k kt ) Variance contribution due to covariances between factors 2 β1 β2 cov( F1 t, F2 t ) + + 2 βk 1 βk cov( Fk 1t, Fkt )
Covariance R = α + B F + ε t t t n 1 n 1 n k k 1 n 1 var( R ) =Σ = BΣ B + D = t FM diag( σ,, σ ) 2 2 ε ε,1 ε,n n F D ε Note: cov( R, R ) = β var( F ) β = β ΣFβ it jt i t j i j
Portfolio Analysis w = ( w,, w ) = portfolio weights 1 n R = w R = w α + w BF + w ε pt = n i= 1 = α p t w R i it p = + β F t n i= 1 + ε i i t n n + w i β i F t + i= 1 i= 1 w α + pt t w ε i it
Portfolio Variance Decomposition σ σ σ = var( R ) = w var( R ) w = w BΣ B w + w Dw 2 p R pt 2 p, systematic 2 p, specific = = w BΣ F B w t n 2 = 2 2 p, systematic w Dw wiσ ε, i R p = 2 i= 1 σ p k 2 2 2 p systematic p F p p j jj j= 1 σ, = β Σ β = β, σ + covariance terms covariance terms F σ k 2 2 2 p, systematic β p, j jj j= 1 = σ β σ
Risk Budgeting: Volatility MCR MCR σ p BΣ F B w + Dw = = Marginal contributions w σ p systematic MCR = specific = BΣ Dw σ σ p σ B w F p to risk CR σ p w ( BΣ FBw+ Dw) = w = w σ p Components to risk 1 CR = n CR i = σ i= 1 p
Value-at-Risk (VaR) Tail Risk Measures VaR = q = F α α α 1 ( ) F = CDF of returns R Expected Shortfall (ES) ES = E [ R R VaR ] α α
Tail Risk Measures: Normal Distribution ~ ( μ, σ 2 ), σ 2 = Σ p p p p FM R N w w N α p p α α VaR = μ σ z, z =Φ ( α) ES N α = μ σ φ p p α 1 ( z ) α 1 See functions in PerformanceAnalytics
Tail Risk Measures: Non-NormalNormal Distributions Use Cornish-Fisher expansion to account for asymmetry y and fat tails VaR CF α = μ σ i i z α 1 1 1 + σ ( zα 1) skew ( zα 3zα ) ekurt + ( 2zα 5zα ) skew 6 24 36 2 3 3 2 i i i i 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
Risk Budgeting: Tail Risk Value-at-Risk (VaR) cvar α,i VaR VaR = w = w mvar α n n α i i α, i i= 1 wi i= 1 VaRα mvarα, i = = E[ Ri Rp = VaRα ] wi ces α,i Expected Shortfall (ES) n n ES α ES α = wi = wi mes α, i, w i= 1 i i= 1 ES α mes α, i = = E [ Ri Rp VaR α ] w i,
Risk Budgeting: Explicit Formulas Normal distribution See Jorian (2007) or Dowd (2002) Non-normal distribution ib ti using Cornish-Fisher h expansion See Boudt, Peterson and dc Croux (2008) "Estimation i and Decomposition of Downside Risk for Portfolios with Non-Normal Normal Returns, " Journal of Risk and implementation in PerformanceAnalytics Eric 9ivot 2008
Risk Budgeting: Simulation { R } M simulated returns it M = t= 1 Method 1: Brute Force mvar ΔVaR, mes = α α, i α, i Δw i ΔES Δw α i Method 2: Average R it around values for which R pt = VaR α mvar R, mes R α, i it α, i it tr : = VaR ± ε tr : VaR pt α pt α
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
Unequal Histories Risk factors F F F,, F 1, T k, T 1, T T k, T T i,, F,, Fk 1,1,1 i Fund performance R 1,T R1,T T 1 R nt, R nt, Tn Observe full history Observe partial histories Eric Zivot 9008
Example Portfolio: Unequal Histories of Individual Funds X11316 69 X29554 X165939-0.04 0.00 0 0.02 0.04-0.3-0.2-0.1 0.0 0.1-0.08-0.04 0.00 X15614 45-0.06-0.02 0.02 X153684-0.0 08-0.04 0.0000-0.15-0.10 X104314-0.05 0.00 0.05 1998 2000 2002 2004 2006 2008 1998 2000 2002 2004 2006 2008
Implication of Unequal Histories Can t fit factor models to some funds Need to create proxy factor model Statistics ti ti on common histories i (truncated t data) may be unreliable Difficult to compute non-normal tail risk measures
Extract Data from Database Analysis and Reporting Flow Process Excel Spreadsheets xlsreadwrite R: Fit factor models R data files RODBC Excel Spreadsheets RODBC R: Simulation, portfolio calculations, risk analysis Reports
Factor Model Construction Sufficient i history? No Yes Fit factor model : Variable selection: leaps, MASS Collinearity diagnostics: car dynamic regression: dynlm Create proxy factor model from models with sufficient history R data file
Evaluation of Fitted Factor Models Graphical diagnostics Created plot method appropriate for time series regression. Stability analysis CUSUM etc: strucchange Rolling analysis: rollapply (zoo) Time varying parameters: dlm Dynamic effects dynlm, lmtest
Diagnostic Plots: Example Fund p, Mon nthly performanc ce 0.00 0.02-0.08-0.06-0.04-0.02 Actual Fitted 2005 2006 2007 2008 2009 Index Eric Zivot 2008
Time Series Regression Residual diagnostics PACF ACF -0.2 0.0 0.2 0.4 0.6 0.8 1.0-0.2 0.0 0.2 0.4 0 0.6 0.8 1.0 0 10 20 Density 30 40 50 60 5 10 15 Lag -0.04-0.02 0.00 0.02 Returns OLS-based CUSUM test Empirica al Quantiles -0.04-0.02 0.00 0..02 Empirical fluctu uation process -1.0-0.5 0.00 0.5 1.0 1.5-2 -1 0 1 2 norm Quantiles 0.0 0.2 0.4 0.6 0.8 1.0 Time
24-month rolling estimates X14487 75 X144874 (Intercept) -0.1 0.0-0.05 0.05 0.15 0.25-0.004 0.000 0.004 0.0 X144911 0.1 0.2 0.3 X144887-0.05 0.05 0.15 2007 2008 2009 Index 2007 2008 2009 Index -0.4-0.3-0.2
Dealing with Unequal Histories Estimate conditional distribution of R i given F Fitted factor model or proxy factor model Eti Estimate t marginal lditibti distribution of fff Empirical distribution, multivariate normal, copula Derive marginal distribution of R i from p(r i F) and p(f) Simulate R i and Calculate functional of interest Unobserved performance, Sharpe ratio, ETL etc
Simulation Algorithm Draw { F 1,, F } M by resampling from the empirical distribution of F. For each F F u (u =1 1,, M), drawavalue a R iu, from the estimated conditional distribution of R i given F= F F u (e.g., from fitted factor model assuming normal errors) { R } M iu, is the desired d sample for R u = 1 i M 5000
What to do with R? iu, { } M u = 1 Backfill missing fund performance Compute fund and portfolio performance measures Estimate non-parametric fund and portfolio tail risk ikmeasures Compute non-parametric risk budgeting measures Standard errors can be computed using a bootstrap procedure
Example: Backfilled Fund Performance -0.05 0.00 0.05 1998 2000 2002 2004 2006 Index Eric Zivot 2008
Example: Simulated portfolio distribution 10 20 0 1 Density 30 40 50 60 99 % ModVaR 99% VaR -0.08-0.06-0.04-0.02 0.00 0.02 0.04 Returns
S-PLUS and S+FinMetrics vs R Dealing with time series objects in R can be difficult and confusing timeseries, zoo, xts Time series regression in R is incompletely implemented Diagnostic plots, prediction R packages give about 80% functional coverage to S+FinMetrics
Some Thoughts About Using R in a Corporate Environment IT doesn t want to support it Firewalls block R downloads The world runs from an Excel spreadsheet Analysts with some programming experience learn R quickly Not good for the casual user
References Boudt, K., B. Peterson and C. Croux (2008) "Estimation and Decomposition of Downside Risk for Portfolios with Non- Normal Returns," Journal of Risk Dowd, K. (2002), Measuring Market Risk, John Wiley and Sons Goodworth, T. and C. Jones (2007). Factor-based, Nonparametric Risk Measurement Framework for Hedge Funds and Fund-of-Funds, The European Journal of Finance. Hll Hallerback, kj J. (2003). Decomposing Portfolio Value-at-Risk: A General Analysis, The Journal of Risk 5/2. Jorian, P. (2007), Value at Risk, Third Edition, McGraw Hill
References Jiang, Y. (2009). Overcoming Data Challenges in Fund-of- Funds Portfolio Management, PhD Thesis, Department of Statistics, University of Washington. Lo, A. (2007). Hd Hedge Funds: An Analytic Perspective, Princeton. Yamai, a Y. and T. Yoshiba (2002). Comparative at Analyses of Expected Shortfall and Value-at-Risk: Their Estimation Error, Decomposition, and Optimization, Institute for Monetary and Economic Studies, Bank of Japan.