%Model Description++++++++++++++++++++++++++++++++++
This is a DSGE model describing trade-offs faced by
and open-source programming community


%Model Information++++++++++++++++++++++++++++++++++
Name = Open source programmer DSGE model;



%Parameters+++++++++++++++++++++++++++++++++++++++++
# Utility function parameters
A          = 2.0;
sigma      = 2.0;
# Parameters for production in capital sector
A_k        = 1.0;
alpha_k    = 0.2;
betta_k    = 0.2;
# Parameters for production in project sector
A_p        = 1.0;
alpha_p    = 0.3;
# Parameters for production in human capital sector
A_x        = 1.0;
alpha_x    = 0.5;
# Parameter for open-source time on matching function
xi         = 2.0;
betta      = 0.99;
# Depreciation rates
delta_k    = 0.022;
delta_x    = 0.022;
eta        = 1.0;
ups        = -1.25;
# Matching function parameters
lambdar    = 0.40;
mu         = 0.004;
rho_z      = 0.95;
psi        = 0.07;
# Vacancies cost parameter
a          = 0.05;
c0         = 0.005;
z_bar      = 1.0;
sigma_z    = 0.007;


%Variable Vectors++++++++++++++++++++++++++++++++++++
[1]  n(t):employment{endo}[log,cf]
[2]  np(t):labour_projects{con}[log,cf]
[3]  nos(t):labour_opensource{con}[log,cf]
[4]  nnos(t):labour_non_opensource{con}[log,cf]
[5]  p(t):projects{con}[log,cf]
[6]  pu(t):projects_util{con}[log,cf]
[7]  pk(t):price_capital{con}[log,cf]
[8]  ph(t):price_human{con}[log,cf]
[9]  k(t):physical_capital{endo}[log,cf]
[10] ma(t):labmatch{con}[log,cf]
[11] va(t):vacancies{con}[log,cf]
[12] si(t):search_intensity{con}[log,cf]
[13] v(t):capital_share{con}[log,cf]
[14] z(t):epsz(t):productivity{exo}[log,cf]


%Boundary Conditions+++++++++++++++++++++++++++++++++
None


%Variable Substitution Non-Linear System+++++++++++++
#######################################################
# Definition of leisure
[12]  @L(t)      = 1-n(t-1);
#######################################################
# The utility function and its derivatives
[1]   @U(t)      = ((pu(t)*@L(t)**A)**(1-sigma)-1)/(1-sigma);
[2]   @U_bar     = SS{@U(t)};
[2]   @MUp(t)    = DIFF{@U(t),pu(t)};
[2]   @MUp_bar   = SS{@MUp(t)};
[2]   @MUp(t+1)  = FF_1{@MUp(t)};
[3]   @MUl(t)    = DIFF{@U(t),n(t-1)};
[3]   @MUl_bar   = SS{@MUl(t)};
[3]   @MUl(t+1)  = FF_1{@MUl(t)};
################################################
# The matching function and its derivatives
[3]   @MA(t)     = (va(t)*(nos(t)/nos_bar))**(1-lambdar)*(si(t)*(1-n(t-1)))**lambdar;
[3]   @MA_bar    = SS{@MA(t)};

[4]   @MAv(t)    = DIFF{@MA(t),va(t)};
[5]   @MAv(t+1)  = FF_1{@MAv(t)};
[5]   @MAv_bar   = SS{@MAv(t)};

[4]   @MAn(t)    = DIFF{@MA(t),n(t-1)} ;
[5]   @MAn(t+1)  = FF_1{@MAn(t)};
[4]   @MAn_bar   = SS{@MAn(t)};

[4]   @MAos(t)   = DIFF{@MA(t),nos(t)} ;
[5]   @MAos(t+1) = FF_1{@MAos(t)};
[4]   @MAos_bar  = SS{@MAos(t)};

[4]   @MAsi(t)   = DIFF{@MA(t),si(t)};
[5]   @MAsi(t+1) = FF_1{@MAsi(t)};
[4]   @MAsi_bar  = SS{@MAsi(t)};
##########################################################
# The cost function for search intensity and its derivatives
[10]  @Cs(t)     = c0*si(t)**eta;
[10]  @Cs_bar    = SS{@Cs(t)};
[10]  @Cs(t+1)   = FF_1{@Cs(t)};

[11]  @Css(t)    = DIFF{@Cs(t),si(t)};
[11]  @Css(t+1)  = FF_1{@Css(t)};
[11]  @Css_bar   = SS{@Css(t)};
######################################################
# The vacancy cost function
[11]  @Vac(t)    = a*va(t);
[11]  @Vac_bar   = SS{@Vac(t)};
#######################################################
# Production function in project sector
[11]  @Fp(t)     = A_p*(v(t)*k(t-1))**alpha_p*np(t)**(1-alpha_p);
[11]  @Fp_bar    = SS{@Fp(t)};

[12]  @Fpn(t)    = DIFF{@Fp(t),np(t)};
[12]  @Fpn_bar   = SS{@Fpn(t)};
[12]  @Fpn(t+1)  = FF_1{@Fpn(t)};

[12]  @Fpk(t)    = DIFF{@Fp(t),k(t-1)};
[12]  @Fpk_bar   = SS{@Fpk(t)};
[12]  @Fpk(t+1)  = FF_1{@Fpk(t)};
###########################################################
# Production function in the physical capital sector
[13]  @Fk(t)     = A_k*((1-v(t))*k(t-1))**alpha_k*nnos(t)**betta_k*nos(t)**(1-alpha_k-betta_k);
[12]  @Fk_bar    = SS{@Fk(t)};

[14]  @Fknos(t)  = DIFF{@Fk(t),nnos(t)};
[13]  @Fknos_bar = SS{@Fknos(t)};
[12]  @Fknos(t+1)= FF_1{@Fknos(t)};

[15]  @Fkos(t)   = DIFF{@Fk(t),nos(t)};
[13]  @Fkos_bar  = SS{@Fkos(t)};
[12]  @Fkos(t+1) = FF_1{@Fkos(t)};

[15]  @Fkk(t)    = DIFF{@Fk(t),k(t-1)};
[15]  @Fkk_bar   = SS{@Fkk(t)};
[16]  @Fkk(t+1)  = FF_1{@Fkk(t)};
##########################################################
# Production function in the human capital sector
[13]  @Fx(t)     = A_x*nnos(t)**alpha_x*nos(t)**(1-alpha_x);
[12]  @Fx_bar    = SS{@Fx(t)};

[14]  @Fxnos(t)  = DIFF{@Fx(t),nnos(t)};
[13]  @Fxnos_bar = SS{@Fxnos(t)};
[15]  @Fxnos(t+1)= FF_1{@Fxnos(t)};

[15]  @Fxos(t)   = DIFF{@Fx(t),nos(t)};
[15]  @Fxos_bar  = SS{@Fxos(t)};
[15]  @Fxos(t+1) = FF_1{@Fxos(t)};


%Non-Linear First-Order Conditions+++++++++++++++++++

# Time constraint of only employment, defines n(t-1)
[1]   n(t-1)-nos(t)-nnos(t)-np(t) = 0;

# Matching function labour market, assuming reputational capital is an input, defines ma(t)
[2]   ma(t)-@MA(t) = 0;

# Evolution of total labour, defines n(t)
[3]   n(t)-(1-phi)*n(t-1)-ma(t) = 0;

# Definition of the relative price of physical capital, also FOC w.r.t. capital share v(t), defines pk(t)
[4]   pk(t)-@Fpk(t)/@Fkk(t) = 0;

# Definition of relative price of human capital, defines ph(t)
[5]   ph(t)-(pk(t)*@Fknos(t)-@Fpn(t))/@Fxnos(t) = 0;

# Definition of real budget constraint, defines pu(t)
[6]   pu(t)-@Fpn(t)*np(t)-pk(t)*(@Fknos(t)+@Fkos(t))+@Cs(t)+@Vac(t) = 0;

# Investment physical capital law of motion, defines k(t)
[7]   k(t)-(1-delta_k)*k(t-1)-@Fk(t) = 0;

# Projects production function, defines p(t)
[8]   p(t)-A_p*(v(t)*k(t-1))**alpha_p*np(t)**(1-alpha_p) = 0;

# Euler equation for physical capital
[9]   @MUp(t)*pk(t)-betta*(@MUp(t+1)*@Fpk(t)+@MUp(t+1)*E(t)|pk(t+1)*(1+@Fkk(t+1)-delta_k) = 0;

# Euler equation w.r.t human capital
[10]  @MUp(t)*ph(t)-betta*(@MUp(t+1)*E(t)|ph(t+1)*(1+@Fx(t)-delta_x)+@MUp(t+1)*E(t)|pk(t+1)*@Fknos(t+1)+@MUp(t+1)*@Fpn(t+1)) = 0;

#First-order condition w.r.t open-source programming time
[11]  ((@MUp(t)*pk(t)*@Fkos(t)+@MUp(t)*@Fxos(t))/@MAos(t))-betta*(@MUp(t+1)*(@Fpn(t+1)+@Cs(t+1))+@MUl(t+1)+...
      ((@MUp(t+1)*E(t)|pk(t+1)*@Fkos(t+1)+@MUp(t+1)*@Fxos(t+1))/@MAos(t+1))*((1-psi)+@MAn(t+1))) = 0;

# First-order condition w.r.t. vacancies, va(t)
[12]  (a*@MUp(t)/@MAv(t))-betta*(@MUp(t+1)*(@Fpn(t+1)+@Cs(t+1))+@MUl(t+1)+...
      (a*@MUp(t+1)/@MAv(t+1))*((1-psi)+@MAn(t+1))) = 0;

# Euler equation 3, si(t)
[13]  (@MUp(t)*@Css(t)*(1-n(t-1))/@MAsi(t))-betta*(@MUp(t+1)*(@Fpn(t+1)+@Cs(t+1))+@MUl(t+1)+...
      (@MUp(t+1)*@Css(t+1)*(1-n(t))/@MAsi(t+1))*((1-psi)+@MAn(t+1))) = 0;

# Evolution of exogenous productivity shock
[14]  (E(t)|z(t+1)/z(t)**rho_z)-epsz(t) = 0;


%Manual entry of sstate non-linear system++++++++++++
None


%Steady States [Closed Form]++++++++++++++++++++++++++
[1] inv_bar = delta*k_bar;
[2] vac_bar = a*va_bar;
[3] r_bar   = 1-@Fk_bar+delta
[4] pu_bar  = @Fp_bar;
[6] sic_bar = @Cs_bar;
[7] ma_bar  = @MA_bar;


%Steady State Non-Linear System [Manual]+++++++++++++

# Steady State budget constraint
[1]   pu_bar-@Fpn_bar*np_bar-pk_bar*(@Fknos_bar+@Fkos_bar)+@Cs_bar+@Vac_bar = 0;

# Steady state employment law of motion, i.e. steady state of matches in labour market
[2]   @MA_bar-psi*n_bar = 0;

# Investment physical capital law of motion, defines k(t)
[3]   k_bar-delta_k*@Fk_bar = 0;

# Definition of the relative price of physical capital, also FOC w.r.t. capital share v(t), defines pk(t)
[4]   pk_bar-@Fpk_bar/@Fkk_bar = 0;

# Definition of relative price of human capital, defines ph(t)
[5]   ph_bar-(pk_bar*@Fknos_bar-@Fpn_bar)/@Fxnos_bar = 0;

# Euler equation w.r.t human capital
[6]   @MUp_bar*ph_bar-betta*(@MUp_bar*ph_bar*(1+@Fx_bar-delta_x)+@MUp_bar*pk_bar*@Fknos_bar+@MUp_bar*@Fpn_bar) = 0;

# Physical capital Euler steady state equation
[7]   @MUp_bar*pk_bar-betta*(@MUp_bar*@Fpk_bar+@MUp_bar*pk_bar*(1+@Fkk_bar-delta_k)) = 0;

#First-order condition w.r.t open-source programming time
[8]   ((@MUp_bar*pk_bar*@Fkos_bar+@MUp_bar*@Fxos_bar)/@MAos_bar)-betta*(@MUp_bar*(@Fpn_bar+@Cs_bar)+@MUl_bar+...
      ((@MUp_bar*pk_bar*@Fkos_bar+@MUp_bar*@Fxos_bar)/@MAos_bar)*((1-psi)+@MAn_bar)) = 0;

# Vacancies Euler equation
[9]   (a*@MUp_bar/@MAv_bar)-betta*(@MUp_bar*(@Fpn_bar+@Cs_bar)+@MUl_bar+...
      (a*@MUp_bar/@MAv_bar)*((1-psi)+@MAn_bar)) = 0;
     
# Search Intensity Euler equation
[10]   (@MUp_bar*@Css_bar*(1-n_bar)/@MAsi_bar)-betta*(@MUp_bar*(@Fpn_bar+@Cs_bar)+...
       @MUl_bar+(@MUp_bar*@Css_bar*(1-n_bar)/@MAsi_bar)*((1-psi)+@MAn_bar)) = 0;
      
# Time constraint of only employment, defines n(t-1)
[11]    n_bar-nos_bar-nnos_bar-np_bar = 0;


# For this model, sensible starting values are key to solving the steady state !
[1]  pu_bar    = 1.0;
[2]  pk_bar    = 3.0;
[3]  ph_bar    = 3.0;
[4]  si_bar    = 0.01;
[5]  va_bar    = 0.01;
[6]  k_bar     = 12.0;
[7]  n_bar     = 0.7;
[8]  nnos_bar  = 0.2;
[9]  nos_bar   = 0.2;
[10] np_bar    = 0.3;
[11] v_bar     = 0.5;


%Log-Linearized Model Equations++++++++++++++++++++++
None


%Variance-Covariance Matrix++++++++++++++++++++++++++
Sigma = [sigma_z**2];


%End Of Model File+++++++++++++++++++++++++++++++++++

