[Returnanalytics-commits] r1928 - pkg/PortfolioAnalytics/sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 29 17:12:18 CEST 2012


Author: braverock
Date: 2012-04-29 17:12:18 +0200 (Sun, 29 Apr 2012)
New Revision: 1928

Modified:
   pkg/PortfolioAnalytics/sandbox/script.workshop2012.R
Log:
- move some of the post-processing a little higher in the code

Modified: pkg/PortfolioAnalytics/sandbox/script.workshop2012.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/script.workshop2012.R	2012-04-28 20:39:46 UTC (rev 1927)
+++ pkg/PortfolioAnalytics/sandbox/script.workshop2012.R	2012-04-29 15:12:18 UTC (rev 1928)
@@ -461,6 +461,31 @@
 end_time<-Sys.time()
 end_time-start_time
 
+# Assemble the ex ante result data
+results = c("MeanSD.RND.t", "MeanmETL.RND.t", "MinSD.RND.t", "MinmETL.RND.t", "EqSD.RND.t", "EqmETL.RND.t")
+results.names= c("Eq Wgt", "Mean SD", "Mean mETL", "Min SD", "Min mETL", "Eq SD", "Eq mETL")
+## Extract Weights
+RND.weights = MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$weights #EqWgt
+for(result in results){
+    x=get(result)
+    RND.weights = rbind(RND.weights,x[["2010-12-31"]]$weights)
+}
+rownames(RND.weights)=c(results.names) # @TODO: add prettier labels
+
+## Extract Objective measures
+RND.objectives=rbind(MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$objective_measures[1:3]) #EqWgt
+for(result in results){
+    x=get(result)
+    x.obj=rbind(x[["2010-12-31"]]$objective_measures[1:3])
+    RND.objectives = rbind(RND.objectives,x.obj)
+}
+rownames(RND.objectives)=c("EqWgt",results) # @TODO: add prettier labels
+
+
+#****************************************************************************
+# END main optimization section
+#****************************************************************************
+
 # --------------------------------------------------------------------
 # Chart EqWgt Results against BH RP portfolios
 # --------------------------------------------------------------------
@@ -478,26 +503,7 @@
 # [5] "call"                               "constraints"                       
 # [7] "data_summary"                       "elapsed_time"                      
 # [9] "end_t"      
-# Assemble the ex ante result data
-results = c("MeanSD.RND.t", "MeanmETL.RND.t", "MinSD.RND.t", "MinmETL.RND.t", "EqSD.RND.t", "EqmETL.RND.t")
-results.names= c("Eq Wgt", "Mean SD", "Mean mETL", "Min SD", "Min mETL", "Eq SD", "Eq mETL")
-## Extract Weights
-RND.weights = MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$weights #EqWgt
-for(result in results){
-  x=get(result)
-  RND.weights = rbind(RND.weights,x[["2010-12-31"]]$weights)
-}
-rownames(RND.weights)=c(results.names) # @TODO: add prettier labels
 
-## Extract Objective measures
-RND.objectives=rbind(MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$objective_measures[1:3]) #EqWgt
-for(result in results){
-  x=get(result)
-  x.obj=rbind(x[["2010-12-31"]]$objective_measures[1:3])
-  RND.objectives = rbind(RND.objectives,x.obj)
-}
-rownames(RND.objectives)=c("EqWgt",results) # @TODO: add prettier labels
-
 # --------------------------------------------------------------------
 # Plot Ex Ante scatter of RP and ONLY Equal Weight portfolio
 # --------------------------------------------------------------------
@@ -754,14 +760,14 @@
 # Other things we might do:
 
 ###############
-#GARCH for mu and sigma estimates 3 months out
+#ARMA-GARCH(1,1,1) for mu, sigma, and skew estimates 3 months out
 require(rugarch)
 
 
 ctrl = list(rho = 1, delta = 1e-9, outer.iter = 100, tol = 1e-7)
 spec = ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1,1)),
         mean.model = list(armaOrder = c(1,0), include.mean = TRUE),
-        distribution.model = "std")
+        distribution.model = "ghyp")
 
 dates<-seq.Date(from=as.Date('1975-01-01'), to=as.Date('1996-12-31'),by=1)
 dates<-dates[endpoints(dates,on='months')]
@@ -804,7 +810,13 @@
 names(garch.mu)<-colnames(edhec.R)
 garch.sigma<-foreach(x=iter(garch.out),.combine=cbind)%do% { x$garchdata$fsigma }
 names(garch.sigma)<-colnames(edhec.R)
+garch.skew<-foreach(x=iter(garch.out),.combine=cbind)%do% { x$garchdata$fskew }
+names(garch.skew)<-colnames(edhec.R)
 
+#diagnose skew
+last(garch.skew)
+skewness(tail(edhec.R,36))
+
 #####
 # you can examine the bktest slots using commands like:
 #report(bktest, type="VaR", n.ahead = 1, VaR.alpha = 0.01, conf.level = 0.95)



More information about the Returnanalytics-commits mailing list