Code covered by the BSD License
 GenFirstEigVect(S,A)
 MaxEntropy(G,w_b,w_0,Cons...Nested function that computes fitness
 [E,L,G]=GenPCBasis(S,A)
this function computes the conditional principal portfolios
 [Weights,Ne_s,R_2_s,m_s,s...compute conditional principal portfolios
 S_MAIN.m% this script computes the meandiversification efficient frontier

View all files
Managing Diversification
by
Attilio Meucci
12 Mar 2009
(Updated
09 May 2011)
Entropybased meandiversification efficient frontier

[E,L,G]=GenPCBasis(S,A)

function [E,L,G]=GenPCBasis(S,A)
% this function computes the conditional principal portfolios
% see A. Meucci  "Managing Diversification", Risk Magazine, June 2009
% available at www.ssrn.com
% Code by A. Meucci. This version March 2009.
% Last version available at MATLAB central as "Managing Diversification"
% inputs
% S : covariance matrix
% A : conditioning matrix
% outputs
% E : conditional principal portfolios composition
% L : conditional principal portfolios variances
% G : map weights > conditional diversification distribution (square root of, not normalized)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isempty(A)
N=size(S,1);
K=0;
[E_,L_]=eig(S);
E=E_;
for n=1:N
E(:,n)=E_(:,Nn+1);
L(n)=L_(Nn+1,Nn+1);
end
else
[K,N]=size(A);
E=[];
B=A;
for n=1:NK
if ~isempty(E)
B=[A
E'*S];
end
e=GenFirstEigVect(S,B);
E=[E e];
end
for n=NK+1:N
B=E'*S;
e=GenFirstEigVect(S,B);
E=[E e];
end
% swap order
E=[E(:,NK+1:N) E(:,1:NK)];
end
L=diag(E'*S*E);
G=diag(sqrt(L))*inv(E);
G=G(K+1:N,:);


Contact us