[Returnanalytics-commits] r3127 - pkg/PerformanceAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 17 06:25:58 CEST 2013


Author: rossbennett34
Date: 2013-09-17 06:25:57 +0200 (Tue, 17 Sep 2013)
New Revision: 3127

Modified:
   pkg/PerformanceAnalytics/R/PortfolioRisk.R
Log:
Modifying Portsd so that the asset names are returned with contribution and pct_contrib.

Modified: pkg/PerformanceAnalytics/R/PortfolioRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/PortfolioRisk.R	2013-09-17 04:09:15 UTC (rev 3126)
+++ pkg/PerformanceAnalytics/R/PortfolioRisk.R	2013-09-17 04:25:57 UTC (rev 3127)
@@ -231,10 +231,13 @@
    dpm2 = derportm2(w,sigma)
    dersd = (0.5*as.vector(dpm2))/sqrt(pm2);
    contrib = dersd*as.vector(w)
+   names(contrib) = names(w)
+   pct_contrib = contrib/sqrt(pm2)
+   names(pct_contrib) = names(w)
    # check
    if( abs( sum(contrib)-sqrt(pm2))>0.01*sqrt(pm2)) { print("error") 
    } else {
-       ret<-list(  sqrt(pm2) , contrib , contrib/sqrt(pm2) )
+       ret<-list(  sqrt(pm2) , contrib , pct_contrib )
        names(ret) <- c("StdDev","contribution","pct_contrib_StdDev")
    }
    return(ret)



More information about the Returnanalytics-commits mailing list