
function F = frac_default2(F_bar,sp_bar,MU,sigmav)
% find sigma given foreclosure rate, interest rate spread between lending
% rate and wholesale interest rate and monitoring cost
z_bar = norminv(F_bar,0,1);
omega_bar = exp(sigmav*z_bar - 0.5*sigmav^2);
G_bar = normcdf(z_bar-sigmav,0,1);
Gamma_bar = omega_bar * (1- F_bar) + G_bar;
DG_bar = normpdf(z_bar,0,1)*(1/sigmav);
F = sp_bar * (1-Gamma_bar) + ((1-F_bar)/(1-F_bar - MU * DG_bar))*((Gamma_bar - MU * G_bar)* sp_bar -1);
%F = omega_bar - sp_bar * (Gamma_bar - MU * G_bar);
