[Returnanalytics-commits] r3084 - in pkg/Meucci: R data demo man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 13 13:12:05 CEST 2013


Author: xavierv
Date: 2013-09-13 13:12:03 +0200 (Fri, 13 Sep 2013)
New Revision: 3084

Removed:
   pkg/Meucci/data/MeucciFreaqEst.rda
   pkg/Meucci/data/MeucciTweakTest.rda
Modified:
   pkg/Meucci/R/RobustBayesianAllocation.R
   pkg/Meucci/R/data.R
   pkg/Meucci/demo/FullyFlexibleBayesNets.R
   pkg/Meucci/demo/RobustBayesianAllocation.R
   pkg/Meucci/demo/S_SnPCaseStudy.R
   pkg/Meucci/man/robustBayesianPortfolioOptimization.Rd
Log:
 - fixed variable scope in robustBayesianPortfolioOptimization and two datafiles

Modified: pkg/Meucci/R/RobustBayesianAllocation.R
===================================================================
--- pkg/Meucci/R/RobustBayesianAllocation.R	2013-09-13 10:29:37 UTC (rev 3083)
+++ pkg/Meucci/R/RobustBayesianAllocation.R	2013-09-13 11:12:03 UTC (rev 3084)
@@ -87,6 +87,7 @@
 #' @param mean_post          the posterior vector of means (after blending prior and sample data)
 #' @param cov_post           the posterior covariance matrix (after blending prior and sample data)
 #' @param nu_post            a numeric with the relative confidence in the prior vs. the sample data. A value of 2 indicates twice as much weight to assign to the prior vs. the sample data. Must be greater than or equal to zero
+#' @param time_post          a numeric
 #' @param riskAversionMu     risk aversion coefficient for estimation of means. 
 #' @param riskAversionSigma  risk aversion coefficient for estimation of Sigma.
 #' @param discretizations    an integer with the number of portfolios to generate along efficient frontier (equally distanced in return space). Parameter must be an integer greater or equal to 1.
@@ -111,7 +112,7 @@
 #' \url{ http://papers.ssrn.com/sol3/papers.cfm?abstract_id=681553 }
 #' @author Ram Ahluwalia \email{ram@@wingedfootcapital.com}
 #' @export
-robustBayesianPortfolioOptimization = function( mean_post , cov_post , nu_post , riskAversionMu = .1 , riskAversionSigma = .1 , discretizations = 10 , longonly = FALSE , volatility )
+robustBayesianPortfolioOptimization = function( mean_post , cov_post , nu_post , time_post, riskAversionMu = .1 , riskAversionSigma = .1 , discretizations = 10 , longonly = FALSE , volatility )
 {    
   # parameter checks    
   N = length( mean ) # number of assets    

Modified: pkg/Meucci/R/data.R
===================================================================
--- pkg/Meucci/R/data.R	2013-09-13 10:29:37 UTC (rev 3083)
+++ pkg/Meucci/R/data.R	2013-09-13 11:12:03 UTC (rev 3084)
@@ -238,4 +238,13 @@
 #' @references A. Meucci, "Fully Flexible Views: Theory and Practice", The Risk Magazine,
 #' October 2008, p 100-106. \url{http://symmys.com/node/158}
 #' @keywords data
+NULL
+
+#' @title scenarios table and prior distribution for changes in SWAP2YR SWAP10YR CDXIG S&P500 DollarIndex Crude Gold VIX 10YRInflationSwapRate
+#'
+#' @name freaqEst
+#' @docType data
+#' @author Xavier Valls\email{flamejat@@gmail.com}
+#' @references A. Meucci, "Stress-Testing with Fully Flexible Causal Inputs" \url{http://symmys.com/node/152}
+#' @keywords data
 NULL
\ No newline at end of file

Deleted: pkg/Meucci/data/MeucciFreaqEst.rda
===================================================================
(Binary files differ)

Deleted: pkg/Meucci/data/MeucciTweakTest.rda
===================================================================
(Binary files differ)

Modified: pkg/Meucci/demo/FullyFlexibleBayesNets.R
===================================================================
--- pkg/Meucci/demo/FullyFlexibleBayesNets.R	2013-09-13 10:29:37 UTC (rev 3083)
+++ pkg/Meucci/demo/FullyFlexibleBayesNets.R	2013-09-13 11:12:03 UTC (rev 3084)
@@ -8,15 +8,14 @@
 # upload scenarios table and prior distribution for changes in
 # SWAP2YR SWAP10YR CDXIG S&P500 DollarIndex Crude Gold VIX 10YRInflationSwapRate
 library( matlab )
-data( "MeucciFreaqEst" ) 
-Names = unlist( Names )
-colnames( X ) = colnames( DY ) = colnames( Data ) = Names
-rownames( Data ) = Dates
+data( "freaqEst" ) 
+colnames( freaqEst$X ) = colnames( freaqEst$DY ) = colnames( freaqEst$Data ) = freaqEst$Names
+rownames( freaqEst$Data ) = freaqEst$Dates
 
-J = nrow( X ) ; N = ncol( X )
-e = .01
+J = nrow( freaqEst$X ) ; N = ncol( freaqEst$X )
+e = 0.01
 p = ( 1 - e ) * p + e * ones( J , 1 ) / J # assigns a minimum probability to each scenario of e * number of scenarios
-moments = ComputeMoments( X , p )
+moments = ComputeMoments( freaqEst$X , p )
 m = moments$means ; s = moments$sd ; C = moments$correlationMatrix ; rm( moments )
 
 ##################################################################################
@@ -76,12 +75,12 @@
 View[[k]]$c = .1
 
 # create linear constraint representation of views on probabilities
-constraints = CondProbViews( View , X )
+constraints = CondProbViews( View , freaqEst$X )
 A = constraints$A ; b = constraints$b ; g = constraints$g ; rm( constraints )
 
 # add constraint for view on correlation
 C_12_ = .6
-New_A = t( X[ , 1 ] * X[ , 2 ] )
+New_A = t( freaqEst$X[ , 1 ] * freaqEst$X[ , 2 ] )
 New_b = s[1] * s[2] * C_12_ + m[1] * m[2]
 New_g = -log( 1 - .1 )
 

Modified: pkg/Meucci/demo/RobustBayesianAllocation.R
===================================================================
--- pkg/Meucci/demo/RobustBayesianAllocation.R	2013-09-13 10:29:37 UTC (rev 3083)
+++ pkg/Meucci/demo/RobustBayesianAllocation.R	2013-09-13 11:12:03 UTC (rev 3084)
@@ -76,6 +76,7 @@
   frontierResults = robustBayesianPortfolioOptimization( mean_post = mean_post , 
                                                          cov_post = cov_post , 
                                                          nu_post = nu_post ,
+                                                         time_post = time_post,
                                                          riskAversionMu = p_m , 
                                                          riskAversionSigma = p_s , 
                                                          discretizations = NumPortf ,

Modified: pkg/Meucci/demo/S_SnPCaseStudy.R
===================================================================
--- pkg/Meucci/demo/S_SnPCaseStudy.R	2013-09-13 10:29:37 UTC (rev 3083)
+++ pkg/Meucci/demo/S_SnPCaseStudy.R	2013-09-13 11:12:03 UTC (rev 3084)
@@ -6,8 +6,8 @@
 
 load("SectorsSnP500")
 
-p_m = .1 # aversion to estimation risk for mu
-p_s = .1 # aversion to estimation risk for sigma
+p_m = 0.1 # aversion to estimation risk for mu
+p_s = 0.1 # aversion to estimation risk for sigma
 
 Ps <- P[seq(from=1, to=nrow(P),by=5),]
 R <- data.frame((Ps[2:nrow(Ps),]/Ps[1:nrow(Ps)-1,]) - 1)

Modified: pkg/Meucci/man/robustBayesianPortfolioOptimization.Rd
===================================================================
--- pkg/Meucci/man/robustBayesianPortfolioOptimization.Rd	2013-09-13 10:29:37 UTC (rev 3083)
+++ pkg/Meucci/man/robustBayesianPortfolioOptimization.Rd	2013-09-13 11:12:03 UTC (rev 3084)
@@ -1,83 +1,86 @@
-\name{robustBayesianPortfolioOptimization}
-\alias{robustBayesianPortfolioOptimization}
-\title{Construct a Bayesian mean-variance efficient frontier and identifies the most robust portfolio}
-\usage{
-  robustBayesianPortfolioOptimization(mean_post, cov_post,
-    nu_post, riskAversionMu = 0.1, riskAversionSigma = 0.1,
-    discretizations = 10, longonly = FALSE, volatility)
-}
-\arguments{
-  \item{mean_post}{the posterior vector of means (after
-  blending prior and sample data)}
-
-  \item{cov_post}{the posterior covariance matrix (after
-  blending prior and sample data)}
-
-  \item{nu_post}{a numeric with the relative confidence in
-  the prior vs. the sample data. A value of 2 indicates
-  twice as much weight to assign to the prior vs. the
-  sample data. Must be greater than or equal to zero}
-
-  \item{riskAversionMu}{risk aversion coefficient for
-  estimation of means.}
-
-  \item{riskAversionSigma}{risk aversion coefficient for
-  estimation of Sigma.}
-
-  \item{discretizations}{an integer with the number of
-  portfolios to generate along efficient frontier (equally
-  distanced in return space). Parameter must be an integer
-  greater or equal to 1.}
-
-  \item{longonly}{a boolean for suggesting whether an asset
-  in a portfolio can be shorted or not}
-
-  \item{volatility}{a numeric with the volatility used to
-  calculate gamma-m. gamma-m acts as a constraint on the
-  maximum volatility of the robust portfolio. A higher
-  volatility means a higher volatile robust portfolio may
-  be identified.}
-}
-\value{
-  a list of portfolios along the frontier from least risky
-  to most risky bayesianFrontier a list with portfolio
-  along the Bayesian efficient frontier. Specifically:
-  returns: the expected returns of each portfolio along the
-  Bayesian efficient frontier volatility: the expected
-  volatility of each portfolio along the Bayesian efficient
-  frontier weights: the weights of each portfolio along the
-  Bayesian efficient frontier robustPortfolio the most
-  robust portfolio along the Bayesian efficient frontier.
-  Specifically: returns: the expected returns of each
-  portfolio along the Bayesian efficient frontier
-  volatility: the expected volatility of each portfolio
-  along the Bayesian efficient frontier weights: the
-  weights of each portfolio along the Bayesian efficient
-  frontier
-
-  \deqn{ w_{rB}^{(i)} = argmax_{w \in C, w' \Sigma_{1} w
-  \leq \gamma_{\Sigma}^{(i)} } \big\{w' \mu^{1} - \gamma
-  _{\mu} \sqrt{w' \Sigma_{1} w} \big\}, \gamma_{\mu} \equiv
-  \sqrt{ \frac{q_{\mu}^{2}}{T_{1}} \frac{v_{1}}{v_{1} - 2}
-  } \gamma_{\Sigma}^{(i)} \equiv \frac{v^{(i)}}{ \frac{
-  \nu_{1}}{\nu_{1}+N+1} + \sqrt{
-  \frac{2\nu_{1}^{2}q_{\Sigma}^{2}}{ (\nu_{1}+N+1)^{3} } }
-  } }
-}
-\description{
-  Construct a collection of portfolios along the Bayesian
-  mean-variance efficient frontier where each portfolio is
-  equally distanced in return space. The function also
-  returns the most robust portfolio along the Bayesian
-  efficient frontier
-}
-\author{
-  Ram Ahluwalia \email{ram at wingedfootcapital.com}
-}
-\references{
-  A. Meucci - Robust Bayesian Allocation - See formula (19)
-  - (21) \url{
-  http://papers.ssrn.com/sol3/papers.cfm?abstract_id=681553
-  }
-}
-
+\name{robustBayesianPortfolioOptimization}
+\alias{robustBayesianPortfolioOptimization}
+\title{Construct a Bayesian mean-variance efficient frontier and identifies the most robust portfolio}
+\usage{
+  robustBayesianPortfolioOptimization(mean_post, cov_post,
+    nu_post, time_post, riskAversionMu = 0.1,
+    riskAversionSigma = 0.1, discretizations = 10,
+    longonly = FALSE, volatility)
+}
+\arguments{
+  \item{mean_post}{the posterior vector of means (after
+  blending prior and sample data)}
+
+  \item{cov_post}{the posterior covariance matrix (after
+  blending prior and sample data)}
+
+  \item{nu_post}{a numeric with the relative confidence in
+  the prior vs. the sample data. A value of 2 indicates
+  twice as much weight to assign to the prior vs. the
+  sample data. Must be greater than or equal to zero}
+
+  \item{time_post}{a numeric}
+
+  \item{riskAversionMu}{risk aversion coefficient for
+  estimation of means.}
+
+  \item{riskAversionSigma}{risk aversion coefficient for
+  estimation of Sigma.}
+
+  \item{discretizations}{an integer with the number of
+  portfolios to generate along efficient frontier (equally
+  distanced in return space). Parameter must be an integer
+  greater or equal to 1.}
+
+  \item{longonly}{a boolean for suggesting whether an asset
+  in a portfolio can be shorted or not}
+
+  \item{volatility}{a numeric with the volatility used to
+  calculate gamma-m. gamma-m acts as a constraint on the
+  maximum volatility of the robust portfolio. A higher
+  volatility means a higher volatile robust portfolio may
+  be identified.}
+}
+\value{
+  a list of portfolios along the frontier from least risky
+  to most risky bayesianFrontier a list with portfolio
+  along the Bayesian efficient frontier. Specifically:
+  returns: the expected returns of each portfolio along the
+  Bayesian efficient frontier volatility: the expected
+  volatility of each portfolio along the Bayesian efficient
+  frontier weights: the weights of each portfolio along the
+  Bayesian efficient frontier robustPortfolio the most
+  robust portfolio along the Bayesian efficient frontier.
+  Specifically: returns: the expected returns of each
+  portfolio along the Bayesian efficient frontier
+  volatility: the expected volatility of each portfolio
+  along the Bayesian efficient frontier weights: the
+  weights of each portfolio along the Bayesian efficient
+  frontier
+
+  \deqn{ w_{rB}^{(i)} = argmax_{w \in C, w' \Sigma_{1} w
+  \leq \gamma_{\Sigma}^{(i)} } \big\{w' \mu^{1} - \gamma
+  _{\mu} \sqrt{w' \Sigma_{1} w} \big\}, \gamma_{\mu} \equiv
+  \sqrt{ \frac{q_{\mu}^{2}}{T_{1}} \frac{v_{1}}{v_{1} - 2}
+  } \gamma_{\Sigma}^{(i)} \equiv \frac{v^{(i)}}{ \frac{
+  \nu_{1}}{\nu_{1}+N+1} + \sqrt{
+  \frac{2\nu_{1}^{2}q_{\Sigma}^{2}}{ (\nu_{1}+N+1)^{3} } }
+  } }
+}
+\description{
+  Construct a collection of portfolios along the Bayesian
+  mean-variance efficient frontier where each portfolio is
+  equally distanced in return space. The function also
+  returns the most robust portfolio along the Bayesian
+  efficient frontier
+}
+\author{
+  Ram Ahluwalia \email{ram at wingedfootcapital.com}
+}
+\references{
+  A. Meucci - Robust Bayesian Allocation - See formula (19)
+  - (21) \url{
+  http://papers.ssrn.com/sol3/papers.cfm?abstract_id=681553
+  }
+}
+



More information about the Returnanalytics-commits mailing list