Credit Contract Enforcement and Income disparities across Indian States

Heterogeneous agents model code

View the Project on GitHub kritikhanna/ContractEnforcement-GE

This page contains full matlab code and explanations for the heterogeneous agents - occupational choices model I use to study income disparities across Indian states.

Dissertation

On this webpage, there are three types of files:

  1. m: matlab m file
  2. publish html: html files generated by matlab publish
  3. profile: html files generated by profiling the m file with timing results

Matlab .m files are either function files (performing a small functionality of the code) or tester files (testing correctness these small functionalities). All function/tester files can be run independently.

Code is divided into sections (1) - (4).

Section (1) contains functions for solving the heterogeneous firm’s maximization problem

Section (2) contains the functions for solving the individual’s Static Occupational Choice Problem

Section (3) contains the functions for solving the individual’s dynamic asset choice problem

Section (4) contains the functions for solving the PE

Section (5) contains the functions for solving the GE

Section (6) contains the functions for calibrating the model

Parameters used in the model are defined here: Model Parameters
Functions Flowchart: Functions Flowchart

Exogeneous Processes

  1. mytauchen_z.m : Discretization of AR(1) entrepreneurial productivity z: Publish , Profile
  2. mytauchen_l.m : Discretization of AR(1) labor productivity l: Publish , Profile

Section 1 : Firm’s maximization problem

1.1 con_kl.m : Publish , Profile

This function computes the constraint on renting of capital and corresponding optimal labor for all combinations of state of assets and productivity, based on degree of imperfect enforcement of contract. Uses 3 methods for computing constrained k,l : numerical, vectorized and taylor series

Fastest version speed: 0.865 s (a X z is 5X6)
Subfunctions: conkl_numerical.m
Testers:

Images from main function: Kconst_az.png , Lconst_az.png, taylor.png
Images from testers: plotconkl.png, plotconkl_a.png, plotconkl_z.png, plotconkl_phi.png Kconst_rw.png, Lconst_rw.png

1.2 optikl.m : Publish , Profile

This function computes the firm profit maximing choice of capital and labor (given the constraint on capital due to imperfect enforceability) for all states of assets and entrepreneurial productivity of individuals. Calls function con_kl.m for noting the constraint on capital and labor before solving the optimal k and l.

Fastest version speed: 0.609 s (a X z is 5X6)
Subfunctions: con_kl.m
Testers:

Images from main function: Optimum_k.png , Optimum_l.png, Optimum_2D.png
Images from testers: kstar_rw.png, lstar_rw.png

Section 2 : Individual’s static occupational choice problem

2.1 OC2.m : Publish, Profile

Determines the static occupational choice for an individual given their state of assets and productivity. Occupational choice is between worker and Entrepreneur. Takes optikl.m as input for computing profits as an entrepreneur, which is important to make the occupational choice. Generates 2 outputs: Optimal Occupational Choice and profit/wage earned.

Fastest version speed: 2.609 s (a X z is 5X6)
Subfunctions: optikl.m
Images from main function: OC2.png

2.1.2 OC3.m : Publish, Profile

Determines the static occupational choice between worker, formal firm owner and informal firm owner. Takes optikl.m as inputs for computing profits as an formal firm/informal firm owner which are important to make the occupational choice. Generates outputs: Optimal Occupational Choice and COH, capital and labor

Fastest version speed: 2.81 s (a X z is 5X6)
Subfunctions: optikl.m
Images from main function: OC3_nolaskills.png,OC3_laskills.png

Alternate informal defn: OC3_2.m

2.1.2.4 OC4.m Publish

4 Occupational type with casual worker.

Section 3 : Individual’s dynamic asset choice problem

The aim of this part of the code is to solve the individual’s dynamic asset problem given wage and interest rates.

Individuals arrive in a period with accumulated assets and a persistent entrepreneurial productivity shock. They decide their occupational choice and the optimal savings to carry forward to the next period. Simulating the entrepreneurial productivity process and optimal choices for heterogeneous agents, the outcome of this problem is a joint steady state distribution of assets and productivity given the wage and interest rate.

3.1.1 hhsave_util_2OC.m: Publish, Profile

This function evaluates the utility at each combination of current assets, entrepreneurial productivity and future assets a’ for a 2 OC model. Takes COH as input from OC2.m function.

Fastest version speed: 2.477 s (a X z is 5X6)
Subfunctions: OC2.m

3.1.2 hhsave_util_3OC.m: Publish, Profile

This function evaluates the utility at each combination of current assets, entrepreneurial productivity, labor opportunity and future assets a’ for a 3 OC model. Takes COH as input from OC3 function.

Fastest version speed: 3.383 s (a X z X s is 5X6X2)
Subfunctions: OC3.m

3.2.1 hhsave_VFI_2OC.m :Publish, Profile

This function solves the dynamic programming problem and generates the value function/policy function for a 2 OC model.

Fastest version speed: 2.594 s (a X z is 25X10)
Subfunctions: hhsave_util_2OC
Testers:

Images from main function: Valuefunction_3D.png,
Valuefunction_2D.png, Policyfunction.png, Consumption.png

3.2.2 hhsave_VFI_3OC.m :Publish, Profile

With uneven denser grid for small asset choices : hhsave_VFI_3OC_powerspace.m

This function solves the dynamic programming problem and generates the value function/policy function for a 3 OC model.

Fastest version speed: 7.448 s (a X z is 6X5)
Subfunctions: hhsave_util_3OC
Testers:

Images from main function: Valuefunction_3D_0.png,Valuefunction_3D_1.png
Valuefunction_2D_0.png, Valuefunction_2D_1.png Policyfunction_0.png,Policyfunction_1.png Consumption_0.png, Consumption_1.png

3.3.1 hhsave_dis_2OC.m :Publish, Profile

Solve Stationary Distribution of the 2 OC problem given wages and interest rates.

3.3.2 hhsave_dis_3OC.m :Publish, Profile

Solve Stationary Distribution of the 3 OC problem given wages and interest rates.

Section 4 : Partial Equililbrium

4.1 PE_2OC.m: Publish, Profile

Solve for model outcomes including aggregate capital, labor demanded and supplied given interest rates and wages for 2 OC problem

4.2 PE_3OC.m: Publish, Profile

Solve for model outcomes including aggregate capital, labor demanded and supplied given interest rates and wages for 3 OC problem

Tester: tester_PE_3OC
Computing statistics: Stats_PE

Section 5 : General Equililbrium

Solving model outcomes at General Equilibrium

5.1 GE_2OC.m: Publish

5.2 GE_3OC.m: Publish

Tester: tester_GE_3OC

Original Paper: Credit Contract Enforcement and Income Disparities across Indian States