Pretty Correlation Map of PIMCO Funds
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
As PIMCO expands beyond fixed income, I thought it might be helpful to look at correlation of PIMCO mutual funds to the S&P 500. Unfortunately due to the large number of funds, I cannot use the chart.Correlation from PerformanceAnalytics. I think I have made a pretty correlation heatmap of PIMCO institutional share funds with inception prior to 5 years ago. Of course this eliminates many of the new strategies, but it is easy in the code to adjust the list. I added the Vanguard S&P 500 fund (VFINX) as a reference point. Then, I orderded the correlation heat map by correlation to VFINX.
As expected there are two fairly distinct groups of funds: those (mostly fixed income) with negative/low correlation to the S&P 500 and those with strong positive correlation.
![]() |
From TimelyPortfolio |
Here is the more standard heat map with dendrogram ordering, which has its purpose but gets a little busy.
![]() |
From TimelyPortfolio |
If we are only interested in the correlation to the S&P 500 (VFINX), then this might be more helpful.
![]() |
From TimelyPortfolio |
#do a pretty correlation on heat map on all Pimco Funds (institutional share class) that have existed longer 5 years | |
#symbol list obtained from | |
#http://investments.pimco.com/Products/pages/PlOEF.aspx?Level1=ulProducts&Center=ulProducts&Level2=liulProductsMutualFunds | |
#pasted into Excel and sorted by 5 yr return | |
#then copied and pasted transpose | |
#saved to csv | |
#and pasted in this ticker list eliminating the money fund and adding Vanguard S&P 500 for reference | |
tckrs <- c("PISIX","PSKIX","PSDIX","PSTKX","PCRIX","PFIIX","PHMIX","PFCIX","PCDIX","PTSHX","PFMIX","PLMIX","PSPTX","PCIMX","PSTIX","PNYIX","PLDTX","PLDIX","PTLDX","PAAIX","PXTIX","PHIYX","PSCSX","PAUIX","PTRIX","PGBIX","PFORX","PELBX","PDMIX","PMDRX","PEBIX","PDIIX","PRRSX","PMBIX","PTSAX","PTTRX","PIGLX","PRRIX","PFUIX","PIMIX","PIGIX","PRAIX","PLRIX","PGOVX","PEDIX","VFINX") | |
for (i in 1:length(tckrs)) { | |
ifelse (i == 1, | |
pimco <- get(getSymbols(tckrs[i],from="2000-01-01",adjust=TRUE))[,4], | |
pimco <- merge(pimco,get(getSymbols(tckrs[i],get="all",from="2000-01-01",adjust=TRUE))[,4])) | |
} | |
#remove .close from each of the symbols | |
colnames(pimco) <- tckrs | |
pimco.clean <- na.omit(pimco) | |
pimco.roc <- ROC(pimco.clean,n=1,type="discrete") | |
pimco.roc[1,] <- 0 | |
#do correlation table | |
ca <- cor(pimco.roc) | |
#get colors to use for heat map | |
brew <- brewer.pal(name="RdBu",n=5) | |
#get color ramp | |
cc.brew <- colorRampPalette(brew) | |
#apply color ramp | |
cc <- cc.brew(nrow(ca)) | |
#do heatmap and sort by degree of correlation to VFINX (Vanguard S&P 500) | |
heatmap(ca[order(ca[,ncol(ca)]),order(ca[,ncol(ca)])],symm=TRUE,Rowv=NA,Colv=NA,col=cc,RowSideColors=cc,main="") | |
title(main="Correlation Table (Ordered by Correlation with Vanguard S&P 500-VFINX)",font.main=1,outer=TRUE,line=-1,cex.main=1.3) | |
heatmap(ca[order(ca[,ncol(ca)]),order(ca[,ncol(ca)])],symm=TRUE,col=cc,RowSideColors=cc,main="") | |
title(main="Correlation Table (Ordered by Dendrogram)",font.main=1,outer=TRUE,line=-1,cex.main=1.3) | |
#do colors based on correlation but with gray so visible when labelling | |
cc.palette <- colorRampPalette(c(cc[1],"gray60",cc[length(cc)])) | |
cc.levpalette <- cc.palette(nrow(ca)) | |
cc.levels <- level.colors(ca[order(ca[,ncol(ca)-1]),ncol(ca)-1], at = do.breaks(c(-1,1),nrow(ca)), | |
col.regions = cc.levpalette) | |
dotchart(ca[order(ca[,ncol(ca)]),ncol(ca)],col=cc.levels,pch=19,cex=0.75) | |
title(main="Correlation to Vanguard S&P 500 (VFINX)",font.main=1,outer=TRUE,line=-1,cex.main=1.3) |
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.