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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Apr 28 22:39:46 CEST 2012


Author: braverock
Date: 2012-04-28 22:39:46 +0200 (Sat, 28 Apr 2012)
New Revision: 1927

Modified:
   pkg/PortfolioAnalytics/sandbox/script.workshop2012.R
Log:
- fix garch.mu and garch.sigma to have correct dimensions, and n.ahead

Modified: pkg/PortfolioAnalytics/sandbox/script.workshop2012.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/script.workshop2012.R	2012-04-28 19:44:55 UTC (rev 1926)
+++ pkg/PortfolioAnalytics/sandbox/script.workshop2012.R	2012-04-28 20:39:46 UTC (rev 1927)
@@ -193,7 +193,7 @@
 #    as.numeric(StdDev(R=R, weights=weights)*sqrt(4)) # hardcoded for quarterly data
 }
 
-pasd.garch<- function(R,weights.sigmas) {
+pasd.garch<- function(R,weights,sigmas) {
     #sigmas is an input of predicted sigmas on a date, 
     # presumably from a GARCH model
     as.numeric((sigmas[last(index(R)),]*weights)*sqrt(12))
@@ -243,8 +243,9 @@
   #name='pasd.garch', # to minimize from the predicted sigmas
   enabled=TRUE, # enable or disable the objective
   multiplier=0, # calculate it but don't use it in the objective
-  arguments=list() # from inception 
-  )
+  arguments=list() # from inception for pasd 
+  #arguments=list(sigmas=garch.sigmas) # from inception for pasd.garch 
+)
 # Add measure 3, CVaR with p=(1-1/12)
 
 # set confidence for VaR/ES
@@ -790,12 +791,12 @@
             solver = "solnp", fit.control = list(), solver.control = ctrl,
             calculate.VaR = TRUE, VaR.alpha = c(0.01, 0.025, 0.05))
     
-    rawgarchdata<-as.data.frame(bktest)
+    rawgarchdata<-as.data.frame(bktest, n.ahead=3) # extract the 3rd n.ahead estimate
     rawgarchdata.xts<-xts(rawgarchdata[,2:5],order.by=as.Date(rawgarchdata[,1]))
     garchdata<-rawgarchdata.xts[index(oridata)]
     
     
-    out<-list(bktest=bktest,spec=spec,oridata=oridata,data=data,rawgarchdata=rawgarchdata.xts,garchdata=garchdata)
+    out<-list(bktest=bktest,spec=spec,oridata=oridata,data=data,rawgarchdata=rawgarchdata.xts,garchdata=garchdata,start=start, end=end)
 }
 names(garch.out)<-colnames(edhec.R)
 # OK, so now we've got a big unweildy GARCH list.  let's create garchmu and garchsigma



More information about the Returnanalytics-commits mailing list