%q2001b.m
% asset and liability
% cash, bonds, stocks

% assets
e = [0 2 6];
sd = [0 10 18];
cc = [1 0 0; 0  1 .4; 0 .4 1];
cv = (sd'*sd).*cc;

% asset covariance matrix
   acv = cv;
   
% liability = .8 bond + .2 stock + residual (std = 2)
 bliab = [.8 .2];
 rvliab = 2^2;

% add liability
e = [e 0];
cv = [ cv [0;0;0] ; [0 0 0 0]];
cv(2,4) = bliab(1)*cv(2,2) + bliab(2)*cv(2,3);
cv(4,2) = cv(2,4);
cv(3,4) = bliab(1)*cv(3,2) + bliab(2)*cv(3,3);
cv(4,3) = cv(3,4);
cv(4,4) = bliab*cv(2:3,2:3)*bliab' + rvliab; 

% CiL values
  ciL = cv(1:3,4);
  
% assume portfolio
x = [0 .4 .6 ];

% Cip values
  cip = acv*x';

  
pause;

% compute marginal risks
