%  lognormal.m
%  Risk premiums with lognormal risks 
%  Graph comparing DA with EU, WU:  rp v variance   
%
format compact
clear all 

disp('***************************************************************')
disp('Lognormal risk premiums for Chew-Dekel preferences') 

alpha = 0.5;
delta = 0.5;
gamma = -0.25;

kappa1 = 0;
kappa2all = [0.0025:0.005:0.6]';

maxit = 10;

muda = 0*kappa2all;
for ikappa = 1:length(kappa2all)
    kappa2 = kappa2all(ikappa);
    sigma = sqrt(kappa2);
    term1 = exp(alpha*kappa1+alpha^2*kappa2/2);
    mu = 1.1;
%    disp('      it      logmu      diff       d         Phi ')
    for it = 1:maxit 
        d1 = (log(mu)-kappa1-alpha*kappa2)/sigma; 
        d2 = (log(mu)-kappa1)/sigma; 
        Phi1 = 0.5*(erf(d1/sqrt(2))+1);
        Phi2 = 0.5*(erf(d2/sqrt(2))+1);
        munext = term1+delta*(term1*Phi1-Phi2);
        munext = munext^(1/alpha);
        diff = abs(munext-mu); 
%        [it mu diff Phi1 Phi2]
        mu = munext;
        if diff < 1.0e-8, break, end 
    end 
%    [it mu diff Phi1 Phi2]
muda(ikappa) = mu;
end 

rpda = (kappa1+kappa2all/2) - log(muda);
rpeu = (1-alpha)*kappa2all/2;
rpwu = (1-alpha-2*gamma)*kappa2all/2;

%kappa2all = sqrt(kappa2all);

figure(1) 
clf
FontSize=  12;
FontName='Helvetica';
plot(kappa2all,rpda,'LineWidth',1.5,'Color','k','LineStyle','-.')  
hold on
ha = gca;
set(ha,'LineWidth',1,'FontSize',FontSize)
set(ha,'LineWidth',1,'FontSize',11,'FontName',FontName)
plot(kappa2all,rpwu,'LineWidth',1.5,'Color','k','LineStyle','-')  
plot(kappa2all,rpeu,'LineWidth',1.5,'Color','k','LineStyle','--') 
axis([0 0.6 0 0.3])
xlabel('Variance of Log Consumption','FontSize',FontSize,'FontName',FontName)
ylabel('Risk Premium','FontSize',FontSize,'FontName',FontName)
text(0.4,0.08,'Expected Utility','FontSize',FontSize)
text(0.02,0.14,'Disappointment Aversion','FontSize',FontSize) 
text(0.29,0.13,'Weighted Utility','FontSize',FontSize) 

print -deps fig3final.eps

return 