[Returnanalytics-commits] r2219 - pkg/PerformanceAnalytics/sandbox/Meucci/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 30 02:53:46 CEST 2012


Author: mkshah
Date: 2012-07-30 02:53:45 +0200 (Mon, 30 Jul 2012)
New Revision: 2219

Added:
   pkg/PerformanceAnalytics/sandbox/Meucci/R/MeanDiversificationFrontier.R
Log:
Adding a script for "Managing Diversification" part of Meucci's research

Added: pkg/PerformanceAnalytics/sandbox/Meucci/R/MeanDiversificationFrontier.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Meucci/R/MeanDiversificationFrontier.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Meucci/R/MeanDiversificationFrontier.R	2012-07-30 00:53:45 UTC (rev 2219)
@@ -0,0 +1,36 @@
+GenFirstEigVect = function( S , A )
+{
+  N = nrow( S )
+  P = diag( N )
+
+  if ( qr( A )$rank > 0 )
+  {
+    P = diag(N) - t( A ) %*% solve( A  %*% t( A ) ) %*% A
+  }
+
+  tmp = eigen( P %*% S %*% t(P) )
+  E_ = tmp$vectors
+  L_ = tmp$values
+  
+  I = which.max(  L_ )
+  e = E_[,I]
+  
+  return( e )
+}
+
+GenPCBasis = function( S , A )
+{  
+  if ( length( A ) == 0 )
+  {
+    N = nrow( S )
+    K = 0
+    tmp = eigen( S )
+    E_ = tmp$vectors
+    E = E_
+    for ( n in 1:N )
+    {
+      E[ , n ] = E_[ , N - n + 1 ]
+      L[ n ] = L_[ N - n + 1 , N - n + 1 ]
+    }
+  }
+}
\ No newline at end of file



More information about the Returnanalytics-commits mailing list