clear all;
close all;
clc;
% This code is an implementation of a 2x2 limited commitment problem
% there are two states (1 and 2) or (lo and hi)
% 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 (2 equations) - participation constraints
% [1 1]*c=1 (1 equation) - consumptions sum up to total endowment
% w(2)=Uaut(2) (1 equation) - 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.65; %discount factor
y=[0.35; 0.65]; %endowment vector (lo; hi)
pi = 0.75; %transition probability (persistence)
P=[pi,1-pi;1-pi,pi]; %transition matrix
%find autarky levels of utility
Uau=inv(eye(2,2)-beta*P)*(y.^(1-gamma))/(1-gamma);
%check if risk sharing is possible
Upr=(((ones(1,2)*y/2)^(1-gamma))/(1-gamma))/(1-beta);
if max(Uau)