%Econ202B HW#4 Two-sided Lack of Commitment Model Anton Cheremukhin close all; clear all; clc; y=0.2:0.1:0.8; beta=0.6; N=40; s=zeros(N,1); w_s=zeros(N,1); c_s=zeros(N,7); %Case 1: different gammas for i=1:N gamma=0.05+(i-1)*0.1; s(i)=gamma; wmax=y(4); wmin=y(1); %step 1: compute autarky level of utility uy=(y.^(1-gamma))/(1-gamma); ua=uy*ones(7,1)/(7*(1-beta)); %find cutoff level by bisection while abs(wmin-wmax)>0.0001 w=(wmin+wmax)/2; %iterate over w => compute corresponding consumption bundle c=min(max(y,w*ones(size(y))),(1-w)*ones(size(y))); %compute u(c) and the l.h.s. of the binding condition uc=(c.^(1-gamma))/(1-gamma); uwr=(((1-w)^(1-gamma))/(1-gamma)) + beta*uc*ones(7,1)/(7*(1-beta)); if uwr0.0001 w=(wmin+wmax)/2; %iterate over w => compute corresponding consumption bundle c=min(max(y,w*ones(size(y))),(1-w)*ones(size(y))); %compute u(c) and the l.h.s. of the binding condition uc=(c.^(1-gamma))/(1-gamma); uwr=(((1-w)^(1-gamma))/(1-gamma)) + beta*uc*ones(7,1)/(7*(1-beta)); if uwr