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

S_MAIN.m 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this script computes the meandiversification efficient frontier
% 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"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc; clear; close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% inputs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% upload returns covariance and expectations
load Data
% define benchmark and portfolio weights
N=length(Mu);
w_0=ones(N,1)/N;
% define constraints
Constr.A=[eye(N) % longshort constraints...
eye(N)];
Constr.b=[1*ones(N,1)
.1*ones(N,1)];
Constr.Aeq=ones(1,N); % budget constraint...
Constr.beq=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% meandiversification analysis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% meandiversification frontier
[w,Ne_s,R_2_s,m_s,s_s]=MeanTCEntropyFrontier(S,Mu,w_b,w_0,Constr);
% meandiversification of current allocation
m=Mu'*(w_0w_b);
s=sqrt((w_0w_b)'*S*(w_0w_b));
[E,L,G]=GenPCBasis(S,[]);
v_tilde=G*(w_0w_b);
TE_contr=(v_tilde.*v_tilde)/s;
R_2=max(10^(10),TE_contr/sum(TE_contr));
Ne=exp(R_2'*log(R_2));


Contact us