SlideShare a Scribd company logo
1 of 23
Download to read offline
Using R to Characterize
Hedge Fund Clustering
Greg Kapoustin, Principal
AlphaBetaWorks
gregk@alphabetaworks.com
Why do Hedge Funds Exist?
What is Alpha?
What Investors Want
What Investors (Often) Get
Put Differently
What Investors Want What Investors Get
Volatility as Distance
𝜎 𝑝 = 𝑤𝑖 𝑤𝑗
𝑛
𝑗=1
𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗
𝑛
𝑖=1
𝜎𝑖 𝜎𝑖 𝜌𝑖𝑖 = 𝜎𝑖
2
is the variance of asset 𝑖
𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗 = 𝜎(𝑖, 𝑗) is the covariance between
assets 𝑖 and 𝑗.
Systematic Risk Factors
Estimating Factor Exposure
# Exponentially weight observations:
# decay constant (0.02) (36 month ~50% decay)
kExpWeights <- exp(-1 * c(1:kDefaultRegPeriods) * .02)
# Estimate exposures using iterated re-weighted least squares (IWLS)
# Default psi = psi.huber
library(MASS)
rlm(
y ~ x1 + x2 + x3,
weights = head(kExpWeights, length(y)),
acc = 0.01,
na.action = na.fail
)
sMed.X Team optimized the rlm() critical path for AlphaBetaWorks:
• Rewrote QR decomposition in MASS, currently implemented in FORTRAN, called
through a C wrapper:
c original (dqrdc.f) linpack version dated 08/14/78 .
c g.w. stewart, university of maryland, argonne national lab.
c
c this version dated 22 august 1995
c ross ihaka
c
c bug fixes 29 September 1999 BDR (p > n case, inaccurate ranks)
• Added support of a response matrix in a call to rlm(), eliminating the call loop.
• Rewrote the QR algorithm in CUDA-optimized code.
• Achieved >200x performance gain on consumer hardware ($130 NVIDIA GTX 750Ti).
Factor and Residual Distances
𝜎 𝑝 = 𝑤𝑖 𝑤𝑗
𝑛
𝑗=1
𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗
𝑛
𝑖=1
= 𝑤𝑖
2
𝜎𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙 𝑖
2
𝑛
𝑖=1
+ 𝑤𝑖 𝑤𝑗
𝑓
𝑗=1
𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗
𝑓
𝑖=1
Portfolio Distance Function
PortfolioPairTrackingError <- function(port1, port2) {
# Calculate relative security weightings
pos1 <- port1$pos.last[which(port1$pos.last != 0)]
pos2 <- port2$pos.last[which(port2$pos.last != 0)]
secs1 <- names(pos1)
secs2 <- names(pos2)
secs <- union(secs1, secs2)
port <- vector("numeric", length(secs))
names(port) <- secs
port[secs1] <- pos1[secs1]
port[secs2] <- port[secs2] - pos2[secs2]
# Calculate relative residual variance
var.resid <- sum(port ^ 2 * risk.model$sec.info[secs, "ResidVar"])
# Calculate relative factor variance
fact.exps <- port1$fact.exps.last - port2$fact.exps.last
fact.exp.mat <- fact.exps %*% fact.exps
var.fact <- sum(fact.exp.mat * risk.model$fact.cov.mat)
return(sqrt(var.resid + var.fact))
}
Calculating Pairwise Distances
library(doParallel)
n.workers <- 36
# Empty outfile allows forked STDOUT to
# show up in parent's STDOUT.
cl <- makeCluster(n.workers, outfile = "")
registerDoParallel(cl)
# Source data is accessed via global variables.
tracking.errors <- foreach(
port.pair = port.pairs,
.combine = c,
.errorhandling = 'stop',
.verbose = TRUE
) %dopar% PortfolioPairTrackingError(
portfolios[[port.pair$p1]],
portfolios[[port.pair$p2]]
)
stopCluster(cl)
Hedge Fund Distance Matrix
Visualizing the Distance Matrix
# Convert tracking error matrix to distance matrix
plot.d.mat <- as.dist(plot.mat)
# Create clusters
hc <- hclust(plot.d.mat, method = "complete")
# Cut dendrogram cut at h = 10.
# Creates clusters with <= 10% relative tracking errors
clus = cutree(hc, h = 10)
# Plot phylogenic tree of hedge fund portfolios
pal <- rainbow(20)
plot(
as.phylo(hc),
type = "fan",
cex = 0.5,
tip.color = pal[clus],
label.offset = 0.01
)
Hedge Fund Clustering
Hedge Fund Cluster
Hedge Fund Cluster
Cluster’s Factor Bets
Cluster’s Residual Bets
Scary Cluster
Thank You!
Resources
• Wikipedia. Modern portfolio theory.
http://en.wikipedia.org/wiki/Modern_portfolio_theory
• Steve Weston and Rich Calaway (2014, February 26). Getting
Started with doParallel and foreach.
http://cran.r-project.org/web/packages/doParallel/vignettes/gettingstartedParallel.pdf
• Steve Weston (2014, April 10). Using the foreach Package.
http://cran.r-project.org/web/packages/foreach/vignettes/foreach.pdf
• AlphaBetaWorks (2014, October 20). Hedge Fund Clustering.
http://abwinsights.com/2014/10/20/hedge-fund-clustering/
• AlphaBetaWorks Insights and AlphaBetaWorks Charts.
Examples of Financial Analytics in R.
http://abwinsights.com
http://abwcharts.com
Disclaimer
This material has been prepared by Alpha Beta Analytics, LLC, d/b/a AlphaBetaWorks. This material is for information
and illustrative purposes only. It is not, and should not be regarded as investment advice or a recommendation
regarding any particular investment, fund, or course of action. Opinions expressed herein are current opinions as of the
date appearing in this material only and are subject to change without notice. No representation or warranty is being
made that the information herein is accurate, correct, complete, or timely. This information is provided with the
understanding that with respect to the material provided herein, you will make independent decisions with respect to
any course of action in connection herewith. By accepting this material, you acknowledge, understand and accept the
foregoing:
THE PROJECTIONS, FINANCIAL OR OTHERWISE, SET FORTH HEREIN, ARE ESTIMATIONS BASED ON CURRENT
INFORMATION AND RELY ON A NUMBER OF ASSUMPTIONS CONCERNING FUTURE EVENTS AND ARE SUBJECT TO A
NUMBER OF UNCERTAINTIES AND OTHER FACTORS, MANY OF WHICH ARE OUTSIDE THE CONTROL OF
ALPHABETAWORKS. SUCH FACTORS COULD CAUSE ACTUAL RESULTS TO DIFFER MATERIALLY FROM WHAT IS SET FORTH
IN THIS MATERIAL. ALPHABETAWORKS UNDERTAKES NO OBLIGATIONS TO UPDATE OR REVISE ANY OF THE
PROJECTIONS, WHETHER AS A RESULT OF NEW INFORMATION, FUTURE EVENTS OR OTHERWISE. ALPHABETAWORKS
HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED REPRESENTATIONS OR WARRANTIES, WHETHER AT LAW OR IN EQUITY,
INCLUDING AS TO THE ACCURACY OR COMPLETENESS OF, OR REASONABLENESS OF ANY ASSUMPTIONS UNDERLYING
ANY ESTIMATES, PROJECTIONS AND FORECASTS SET FORTH, ANY INFORMATION, DOCUMENTS, OR MATERIALS
REGARDING ALPHABETAWORKS (FURNISHED OR MADE AVAILABLE IN THIS MATERIAL OR OTHER MATERIALS PROVIDED
BY ALPHABETAWORKS).
ANY USE, REPUBLICATION OR REDISTRIBUTION OF THIS MATERIAL AND ITS CONTENT IS EXPRESSLY PROHIBITED
WITHOUT THE PRIOR WRITTEN CONSENT OF ALPHABETAWORKS. BY ACCEPTING THIS MATERIAL YOU AGREE TO NOT
EDIT OR OTHERWISE MODIFY ANY MATERIAL RECEIVED FROM ALPHABETAWORKS, USE ANY ILLUSTRATIONS OR
GRAPHICS SEPARATELY FROM ANY ACCOMPANYING TEXT OR REPRODUCE, DUPLICATE, COPY OR OTHERWISE EXPLOIT
MATERIAL RECEIVED FROM ALPHABETAWORKS.

More Related Content

Similar to Using R to Characterize Hedge Fund Clustering

creditriskmanagment_howardhaughton121510
creditriskmanagment_howardhaughton121510creditriskmanagment_howardhaughton121510
creditriskmanagment_howardhaughton121510mrmelchi
 
Estimating Financial Risk with Apache Spark
Estimating Financial Risk with Apache SparkEstimating Financial Risk with Apache Spark
Estimating Financial Risk with Apache SparkCloudera, Inc.
 
Estimating Value at Risk with Spark
Estimating Value at Risk with SparkEstimating Value at Risk with Spark
Estimating Value at Risk with SparkSandy Ryza
 
Logistic Regression in Case-Control Study
Logistic Regression in Case-Control StudyLogistic Regression in Case-Control Study
Logistic Regression in Case-Control StudySatish Gupta
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
 
An Introduction to Property Based Testing
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based TestingC4Media
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialJeff Smith
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialJeff Smith
 
My Gentle Introduction to RxJS
My Gentle Introduction to RxJSMy Gentle Introduction to RxJS
My Gentle Introduction to RxJSMattia Occhiuto
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Droidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfDroidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfAnvith Bhat
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeMagnify Analytic Solutions
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonfNataliya Patsovska
 
Rx for Android & iOS by Harin Trivedi
Rx for Android & iOS  by Harin TrivediRx for Android & iOS  by Harin Trivedi
Rx for Android & iOS by Harin Trivediharintrivedi
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJSKyung Yeol Kim
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptViliam Elischer
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simplerAlexander Mostovenko
 

Similar to Using R to Characterize Hedge Fund Clustering (20)

creditriskmanagment_howardhaughton121510
creditriskmanagment_howardhaughton121510creditriskmanagment_howardhaughton121510
creditriskmanagment_howardhaughton121510
 
Estimating Financial Risk with Apache Spark
Estimating Financial Risk with Apache SparkEstimating Financial Risk with Apache Spark
Estimating Financial Risk with Apache Spark
 
Estimating Value at Risk with Spark
Estimating Value at Risk with SparkEstimating Value at Risk with Spark
Estimating Value at Risk with Spark
 
Logistic Regression in Case-Control Study
Logistic Regression in Case-Control StudyLogistic Regression in Case-Control Study
Logistic Regression in Case-Control Study
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
An Introduction to Property Based Testing
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based Testing
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
 
My Gentle Introduction to RxJS
My Gentle Introduction to RxJSMy Gentle Introduction to RxJS
My Gentle Introduction to RxJS
 
Introduction to lifecontingencies R package
Introduction to lifecontingencies R packageIntroduction to lifecontingencies R package
Introduction to lifecontingencies R package
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Rxjs kyivjs 2015
Rxjs kyivjs 2015Rxjs kyivjs 2015
Rxjs kyivjs 2015
 
Droidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfDroidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdf
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using Time
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 
Rx for Android & iOS by Harin Trivedi
Rx for Android & iOS  by Harin TrivediRx for Android & iOS  by Harin Trivedi
Rx for Android & iOS by Harin Trivedi
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 

Recently uploaded

Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
03_Emmanuel Ndiaye_Degroof Petercam.pptx
03_Emmanuel Ndiaye_Degroof Petercam.pptx03_Emmanuel Ndiaye_Degroof Petercam.pptx
03_Emmanuel Ndiaye_Degroof Petercam.pptxFinTech Belgium
 
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...ssifa0344
 
The Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfThe Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfGale Pooley
 
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja Nehwal
 
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...Call Girls in Nagpur High Profile
 
The Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdfThe Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdfGale Pooley
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...ssifa0344
 
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptxFinTech Belgium
 
20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdfAdnet Communications
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptxFinTech Belgium
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spiritegoetzinger
 
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services  9892124323 | ₹,4500 With Room Free DeliveryMalad Call Girl in Services  9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free DeliveryPooja Nehwal
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...Call Girls in Nagpur High Profile
 
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptxFinTech Belgium
 
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Call Girls in Nagpur High Profile
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130Suhani Kapoor
 
The Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfThe Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfGale Pooley
 

Recently uploaded (20)

Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
 
Veritas Interim Report 1 January–31 March 2024
Veritas Interim Report 1 January–31 March 2024Veritas Interim Report 1 January–31 March 2024
Veritas Interim Report 1 January–31 March 2024
 
03_Emmanuel Ndiaye_Degroof Petercam.pptx
03_Emmanuel Ndiaye_Degroof Petercam.pptx03_Emmanuel Ndiaye_Degroof Petercam.pptx
03_Emmanuel Ndiaye_Degroof Petercam.pptx
 
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
 
The Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfThe Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdf
 
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
 
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
 
The Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdfThe Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdf
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
 
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
 
20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spirit
 
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services  9892124323 | ₹,4500 With Room Free DeliveryMalad Call Girl in Services  9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free Delivery
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
 
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
 
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
 
The Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfThe Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdf
 

Using R to Characterize Hedge Fund Clustering

  • 1. Using R to Characterize Hedge Fund Clustering Greg Kapoustin, Principal AlphaBetaWorks gregk@alphabetaworks.com
  • 2. Why do Hedge Funds Exist?
  • 6. Put Differently What Investors Want What Investors Get
  • 7. Volatility as Distance 𝜎 𝑝 = 𝑤𝑖 𝑤𝑗 𝑛 𝑗=1 𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗 𝑛 𝑖=1 𝜎𝑖 𝜎𝑖 𝜌𝑖𝑖 = 𝜎𝑖 2 is the variance of asset 𝑖 𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗 = 𝜎(𝑖, 𝑗) is the covariance between assets 𝑖 and 𝑗.
  • 9. Estimating Factor Exposure # Exponentially weight observations: # decay constant (0.02) (36 month ~50% decay) kExpWeights <- exp(-1 * c(1:kDefaultRegPeriods) * .02) # Estimate exposures using iterated re-weighted least squares (IWLS) # Default psi = psi.huber library(MASS) rlm( y ~ x1 + x2 + x3, weights = head(kExpWeights, length(y)), acc = 0.01, na.action = na.fail ) sMed.X Team optimized the rlm() critical path for AlphaBetaWorks: • Rewrote QR decomposition in MASS, currently implemented in FORTRAN, called through a C wrapper: c original (dqrdc.f) linpack version dated 08/14/78 . c g.w. stewart, university of maryland, argonne national lab. c c this version dated 22 august 1995 c ross ihaka c c bug fixes 29 September 1999 BDR (p > n case, inaccurate ranks) • Added support of a response matrix in a call to rlm(), eliminating the call loop. • Rewrote the QR algorithm in CUDA-optimized code. • Achieved >200x performance gain on consumer hardware ($130 NVIDIA GTX 750Ti).
  • 10. Factor and Residual Distances 𝜎 𝑝 = 𝑤𝑖 𝑤𝑗 𝑛 𝑗=1 𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗 𝑛 𝑖=1 = 𝑤𝑖 2 𝜎𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙 𝑖 2 𝑛 𝑖=1 + 𝑤𝑖 𝑤𝑗 𝑓 𝑗=1 𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗 𝑓 𝑖=1
  • 11. Portfolio Distance Function PortfolioPairTrackingError <- function(port1, port2) { # Calculate relative security weightings pos1 <- port1$pos.last[which(port1$pos.last != 0)] pos2 <- port2$pos.last[which(port2$pos.last != 0)] secs1 <- names(pos1) secs2 <- names(pos2) secs <- union(secs1, secs2) port <- vector("numeric", length(secs)) names(port) <- secs port[secs1] <- pos1[secs1] port[secs2] <- port[secs2] - pos2[secs2] # Calculate relative residual variance var.resid <- sum(port ^ 2 * risk.model$sec.info[secs, "ResidVar"]) # Calculate relative factor variance fact.exps <- port1$fact.exps.last - port2$fact.exps.last fact.exp.mat <- fact.exps %*% fact.exps var.fact <- sum(fact.exp.mat * risk.model$fact.cov.mat) return(sqrt(var.resid + var.fact)) }
  • 12. Calculating Pairwise Distances library(doParallel) n.workers <- 36 # Empty outfile allows forked STDOUT to # show up in parent's STDOUT. cl <- makeCluster(n.workers, outfile = "") registerDoParallel(cl) # Source data is accessed via global variables. tracking.errors <- foreach( port.pair = port.pairs, .combine = c, .errorhandling = 'stop', .verbose = TRUE ) %dopar% PortfolioPairTrackingError( portfolios[[port.pair$p1]], portfolios[[port.pair$p2]] ) stopCluster(cl)
  • 14. Visualizing the Distance Matrix # Convert tracking error matrix to distance matrix plot.d.mat <- as.dist(plot.mat) # Create clusters hc <- hclust(plot.d.mat, method = "complete") # Cut dendrogram cut at h = 10. # Creates clusters with <= 10% relative tracking errors clus = cutree(hc, h = 10) # Plot phylogenic tree of hedge fund portfolios pal <- rainbow(20) plot( as.phylo(hc), type = "fan", cex = 0.5, tip.color = pal[clus], label.offset = 0.01 )
  • 22. Resources • Wikipedia. Modern portfolio theory. http://en.wikipedia.org/wiki/Modern_portfolio_theory • Steve Weston and Rich Calaway (2014, February 26). Getting Started with doParallel and foreach. http://cran.r-project.org/web/packages/doParallel/vignettes/gettingstartedParallel.pdf • Steve Weston (2014, April 10). Using the foreach Package. http://cran.r-project.org/web/packages/foreach/vignettes/foreach.pdf • AlphaBetaWorks (2014, October 20). Hedge Fund Clustering. http://abwinsights.com/2014/10/20/hedge-fund-clustering/ • AlphaBetaWorks Insights and AlphaBetaWorks Charts. Examples of Financial Analytics in R. http://abwinsights.com http://abwcharts.com
  • 23. Disclaimer This material has been prepared by Alpha Beta Analytics, LLC, d/b/a AlphaBetaWorks. This material is for information and illustrative purposes only. It is not, and should not be regarded as investment advice or a recommendation regarding any particular investment, fund, or course of action. Opinions expressed herein are current opinions as of the date appearing in this material only and are subject to change without notice. No representation or warranty is being made that the information herein is accurate, correct, complete, or timely. This information is provided with the understanding that with respect to the material provided herein, you will make independent decisions with respect to any course of action in connection herewith. By accepting this material, you acknowledge, understand and accept the foregoing: THE PROJECTIONS, FINANCIAL OR OTHERWISE, SET FORTH HEREIN, ARE ESTIMATIONS BASED ON CURRENT INFORMATION AND RELY ON A NUMBER OF ASSUMPTIONS CONCERNING FUTURE EVENTS AND ARE SUBJECT TO A NUMBER OF UNCERTAINTIES AND OTHER FACTORS, MANY OF WHICH ARE OUTSIDE THE CONTROL OF ALPHABETAWORKS. SUCH FACTORS COULD CAUSE ACTUAL RESULTS TO DIFFER MATERIALLY FROM WHAT IS SET FORTH IN THIS MATERIAL. ALPHABETAWORKS UNDERTAKES NO OBLIGATIONS TO UPDATE OR REVISE ANY OF THE PROJECTIONS, WHETHER AS A RESULT OF NEW INFORMATION, FUTURE EVENTS OR OTHERWISE. ALPHABETAWORKS HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED REPRESENTATIONS OR WARRANTIES, WHETHER AT LAW OR IN EQUITY, INCLUDING AS TO THE ACCURACY OR COMPLETENESS OF, OR REASONABLENESS OF ANY ASSUMPTIONS UNDERLYING ANY ESTIMATES, PROJECTIONS AND FORECASTS SET FORTH, ANY INFORMATION, DOCUMENTS, OR MATERIALS REGARDING ALPHABETAWORKS (FURNISHED OR MADE AVAILABLE IN THIS MATERIAL OR OTHER MATERIALS PROVIDED BY ALPHABETAWORKS). ANY USE, REPUBLICATION OR REDISTRIBUTION OF THIS MATERIAL AND ITS CONTENT IS EXPRESSLY PROHIBITED WITHOUT THE PRIOR WRITTEN CONSENT OF ALPHABETAWORKS. BY ACCEPTING THIS MATERIAL YOU AGREE TO NOT EDIT OR OTHERWISE MODIFY ANY MATERIAL RECEIVED FROM ALPHABETAWORKS, USE ANY ILLUSTRATIONS OR GRAPHICS SEPARATELY FROM ANY ACCOMPANYING TEXT OR REPRODUCE, DUPLICATE, COPY OR OTHERWISE EXPLOIT MATERIAL RECEIVED FROM ALPHABETAWORKS.

Editor's Notes

  1. Hedge funds exist to generate returns which investors can’t achieve passively – active returns.
  2. The primary source of active returns is alpha – returns unattributable to systematic/market risk factors. By definition, alpha can’t be generated with a passive portfolio.
  3. Hedge fund investors seek a portfolio of differentiated managers that consistently generate returns above those they could get passively and cheaply. These managers warrant high fees.
  4. Unfortunately, the typical 2/20 compensation structure rewards funds on returns irrespectively of risk, so funds are incentivized to invest in high-risk passive bets. Hedge fund investors often get a portfolio of undifferentiated managers that consistently generates returns similar to those they could get passively and cheaply.
  5. Investors want a differentiated team of starts but usually get an undifferentiated team of clones. How can R help differentiate between unique and generic? Wouldn’t it be great to have a metric or distance function for hedge funds to identify clones?
  6. Two funds are similar if their expected relative standard deviation of returns (tracking error) is low.
  7. Much of the correlation/covariance among assets is attributable to a handful of systematic sources of risk. About 90% of hedge funds’ monthly long portfolio variance is due to common factors.
  8. We can estimate security exposures to systematic risk factors using linear models.
  9. We can break volatility into idiosyncratic (residual) and systematic (factor) components. The former is security-specific and unattributable to covariance among securities. The latter is attributable to covariance among securities and can be analyzed using factor analysis.
  10. The above formula looks like a vector and a matrix summation. It is and is easy to implement in R. Now we need to do this for 1000s of fund pairs, potentially millions of pairs, and are impatient.
  11. We generate the sequence of portfolio pairs and calculate their relative distances in parallel.
  12. The list can be rolled into a symmetric matrix.
  13. It is hard to see broad structure in the matrix. Fortunately, R has great libraries for visualizing distance matrices.
  14. We will zoom in on the cluster in the top left.
  15. We can unroll the fan diagram into a rectangular representation where distances are clearer.
  16. We can characterize each cluster.
  17. Investors see which funds are unique and which are generic. Which bets are unique and which are generic. Will a pension fund become underfunded if a single bet goes bad because all the other manager are making a similar one?
  18. Clustering can be scary, consisting of a single bet.