[Returnanalytics-commits] r2051 - pkg/PerformanceAnalytics/sandbox/Meucci/demo
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jun 24 17:40:20 CEST 2012
Author: mkshah
Date: 2012-06-24 17:40:19 +0200 (Sun, 24 Jun 2012)
New Revision: 2051
Modified:
pkg/PerformanceAnalytics/sandbox/Meucci/demo/Prior2Posterior.R
Log:
Adding missing statements
Modified: pkg/PerformanceAnalytics/sandbox/Meucci/demo/Prior2Posterior.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Meucci/demo/Prior2Posterior.R 2012-06-23 02:21:09 UTC (rev 2050)
+++ pkg/PerformanceAnalytics/sandbox/Meucci/demo/Prior2Posterior.R 2012-06-24 15:40:19 UTC (rev 2051)
@@ -18,8 +18,8 @@
# analytical representation
N = 2 # market dimension (2 assets)
Mu = zeros( N , 1 )
-r= .6
-Sigma = ( 1 - r ) * eye( N ) + r * ones( N , N ) # nxn correlation matrix with correlaiton 'r' in off-diagonals
+r = .6
+Sigma = ( 1 - r ) * eye( N ) + r * ones( N , N ) # nxn correlation matrix with correlation 'r' in off-diagonals
# numerical representation
J = 100000 # number of scenarios
@@ -46,33 +46,34 @@
# analytical posterior
RevisedMuSigma = Prior2Posterior( Mu , Q , Mu_Q , Sigma , G , Sigma_G )
Mu_ = RevisedMuSigma$M_
+Sigma_ = RevisedMuSigma$S_
# numerical posterior
Aeq = ones( 1 , J ) # constrain probabilities to sum to one...
beq = 1
# create views
- QX = X %*% t(Q) # a Jx1 matrix
+QX = X %*% t(Q) # a Jx1 matrix
- Aeq = rbind( Aeq , t(QX) ) # ...constrain the first moments...
- # QX is a linear combination of vector Q and the scenarios X
+Aeq = rbind( Aeq , t(QX) ) # ...constrain the first moments...
+# QX is a linear combination of vector Q and the scenarios X
- beq = rbind( beq , Mu_Q )
+beq = rbind( beq , Mu_Q )
- SecMom = G %*% Mu_ %*% t(Mu_) %*% t(G) + Sigma_G # ...constrain the second moments...
- # We use Mu_ from analytical result. We do not use Revised Sigma because we are testing whether
- # the numerical approach for handling expectations of covariance matches the analytical approach
- # TODO: Can we perform this procedure without relying on Mu_ from the analytical result?
- GX = X %*% t(G)
+SecMom = G %*% Mu_ %*% t(Mu_) %*% t(G) + Sigma_G # ...constrain the second moments...
+# We use Mu_ from analytical result. We do not use Revised Sigma because we are testing whether
+# the numerical approach for handling expectations of covariance matches the analytical approach
+# TODO: Can we perform this procedure without relying on Mu_ from the analytical result?
+GX = X %*% t(G)
- for ( k in 1:nrow( G ) )
- {
- for ( l in k:nrow( G ) )
- {
- Aeq = rbind( Aeq , t(GX[ , k ] * GX[ , l ] ) )
- beq = rbind( beq , SecMom[ k , l ] )
- }
- }
+for ( k in 1:nrow( G ) )
+{
+ for ( l in k:nrow( G ) )
+ {
+ Aeq = rbind( Aeq , t(GX[ , k ] * GX[ , l ] ) )
+ beq = rbind( beq , SecMom[ k , l ] )
+ }
+}
emptyMatrix = matrix( , nrow = 0 , ncol = 0 )
p_ = EntropyProg( p , emptyMatrix , emptyMatrix , Aeq , beq ) # ...compute posterior probabilities
More information about the Returnanalytics-commits
mailing list