clear all;
close all;
clc;
% This code is an implementation of a 7x2 limited commitment problem
% there are seven states and two agents
% there are also promised utilities w and consumption values c,
% corresponding to each state
%
% The equations we need to solve in general look the following way:
% w=u(c)+beta*P*w (7 equations) - participation constraints
% M*c=1 (4 equations) - consumptions sum up to total endowment
% w(hi)=max(Uaut(hi),U(1/2)) (3 equations) - in high endowment states agents are guaranteed autarky values at least
global beta gamma P y Uau Upr
%parameters
gamma = 2; %risk aversion
beta = 0.75; %discount factor
%y=[0.35; 0.4; 0.45; 0.5; 0.55; 0.6; 0.65]; %endowment vector (lo; hi)
y=[0.2; 0.3; 0.4; 0.5; 0.6; 0.7; 0.8]; %endowment vector (lo; hi)
pi = 0.75; %transition probability (persistence)
P=(ones(7,7)-eye(7,7))*(1-pi)/6+eye(7,7)*pi;
%find autarky levels of utility
Uau=inv(eye(7,7)-beta*P)*(y.^(1-gamma))/(1-gamma);
%check if risk sharing is possible
Upr=(((ones(1,7)*y/7)^(1-gamma))/(1-gamma))/(1-beta);
if max(Uau)