Code covered by the BSD License

# Risk and Asset Allocation

### Attilio Meucci (view profile)

16 Nov 2005 (Updated )

Software for quantitative portfolio and risk management

S_AnalyzeNormalCorrelation.m
```% this script analyzes the correlation of two jointly normal variables
% in terms of the condition ratio of the eigenvalues
% see "Risk and Asset Allocation"-Springer (2005), by A. Meucci

clc; clear; close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% input parameters

Mu=[0 0]';
s=[1 1];
rhos=[-.99 : .01 : .99];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for n=1:length(rhos)
rho=rhos(n);
Sigma=[s(1)^2     rho*s(1)*s(2)
rho*s(1)*s(2)    s(2)^2];

Covariance=Sigma;
Standard_Deviation=sqrt(diag(Covariance));
Correlation=diag(1./Standard_Deviation)*Covariance*diag(1./Standard_Deviation);

Lambda=eig(Covariance);

Cs(n)=Correlation(1,2);
CRs(n)=min(Lambda)/max(Lambda);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure

subplot(2,1,1)
plot(rhos,Cs)
ylim([-1 1])
grid on
xlabel('rho')
ylabel('correlation')

subplot(2,1,2)
plot(rhos,CRs)
ylim([0 1])
grid on
xlabel('rho')
ylabel('condition ratio')```