In [1]:
using NLsolve
using PyPlot
In [2]:
# model parameters
Cv=.2;
psi1=1.05;
alpha=0.1;
epsilon=1.0;
hbar=1.0;
gamma=.85;
mu=0.9;
In [3]:
function h(ps::Float64,c::Float64,q)
hfunc=(((1+ps)/ps)*(c./q)).^(1/(1+ps))
end
Out[3]:
In [4]:
function nflex(eps,aa::Float64,ps::Float64,c::Float64,q)
nfunc=(eps*aa).^(1/(1-aa)).*((1+1/ps)*(c./q)).^(-(1-aa+ps)/((1-aa)*(1+ps)))
end
Out[4]:
In [5]:
function nfix(eps,aa::Float64,ps::Float64,c::Float64,q,hb::Float64)
nfunc=(eps*aa*hb^aa).^(1/(1-aa)).*(((hb^(1+ps))/(1+ps))+(c./q)).^(1/(aa-1))
end
Out[5]:
In [ ]:
In [ ]:
In [6]:
function q(mm::Float64,gg::Float64,n)
(mm*((1-n)./n).^gg).^(1/(1-gg))
end
Out[6]:
In [ ]:
In [7]:
function g!(x,fvec)
# x[1]=h; x[2]=n; x[3]=q;
fvec[1]=x[1]-h(psi1,Cv,x[3])
fvec[2]=x[2]-nflex(epsilon,alpha,psi1,Cv,x[3])
fvec[3]=x[3]-q(mu,gamma,x[2])
end
function g2!(x2,g2vec)
# x[1]=h1; x[2]=h2; x[3]=n1; x[4]=n2; x[5]=q;
g2vec[1]=x2[1]-h(psi1,Cv,x2[5])
g2vec[2]=x2[2]-h(psi1,Cv,x2[5])
g2vec[3]=x2[3]-nflex(epsilon,alpha,psi1,Cv,x2[5])
g2vec[4]=x2[4]-nflex(1,alpha,psi1,Cv,x2[5])
g2vec[5]=x2[5]-q(mu,gamma,x2[3]+x2[4])
end
function g2fix!(x2fix,g2fixvec)
# x[1]=n1; x[2]=n2; x[3]=q;
g2fixvec[1]=x2fix[1]-nfix(epsilon,alpha,psi1,Cv,x2fix[3],hvec1[end])
g2fixvec[2]=x2fix[2]-nfix(1,alpha,psi1,Cv,x2fix[3],hvec1[end])
g2fixvec[3]=x2fix[3]-q(mu,gamma,x2fix[1]+x2fix[2])
end
Out[7]:
In [8]:
hvec1=Array{Float64,1}(0)
hvec2=Array{Float64,1}(0)
nvec1=Array{Float64,1}(0)
nvec2=Array{Float64,1}(0)
qvec=Array{Float64,1}(0)
for eps=.1:.01:1
epsilon=eps;
r=nlsolve(g2!, [ 1.0; 1.0; .1; .1; .1])
push!(hvec1,r.zero[1])
push!(hvec2,r.zero[2])
push!(nvec1,r.zero[3])
push!(nvec2,r.zero[4])
push!(qvec,r.zero[5])
end
hvecfix1=Array{Float64,1}(0)
hvecfix2=Array{Float64,1}(0)
nvecfix1=Array{Float64,1}(0)
nvecfix2=Array{Float64,1}(0)
qvecfix=Array{Float64,1}(0)
for eps=.1:.01:1
epsilon=eps;
rfix=nlsolve(g2fix!, [.1; .1; .05])
push!(hvecfix1,hvec1[end])
push!(hvecfix2,hvec2[end])
push!(nvecfix1,rfix.zero[1])
push!(nvecfix2,rfix.zero[2])
push!(qvecfix,rfix.zero[3])
end
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [9]:
function eqfixedhours!(var,residuals)
# x[1]=n1; x[2]=n2; x[3]=q;
residuals[1]=alpha*hbar*epsilon*(var[1]*hbar)^(alpha-1)-(1/(1+psi1))*hbar^(1+psi1)-Cv/var[3]
residuals[2]=alpha*hbar*1*(var[2]*hbar)^(alpha-1)-(1/(1+psi1))*hbar^(1+psi1)-Cv/var[3]
residuals[3]=var[3]-q(mu,gamma,var[1]+var[2])
end
function eqflexiblehours!(var,residuals)
# x[1]=n1; x[2]=n2; x[3]=h1; x[4]=h2; x[5]=q
residuals[1]=alpha*var[3]*epsilon*(var[1]*var[3])^(alpha-1)-(1/(1+psi1))*var[3]^(1+psi1)-Cv/var[5]
residuals[2]=alpha*var[4]*1*(var[2]*var[4])^(alpha-1)-(1/(1+psi1))*var[4]^(1+psi1)-Cv/var[5]
residuals[3]=alpha*epsilon*(var[1]*var[3])^(alpha-1)-var[3]^psi1
residuals[4]=alpha*1*(var[2]*var[4])^(alpha-1)-var[4]^psi1
residuals[5]=var[5]-q(mu,gamma,var[1]+var[2])
end
Out[9]:
In [10]:
hvec1flexible=Array{Float64,1}(0)
hvec2flexible=Array{Float64,1}(0)
nvec1flexible=Array{Float64,1}(0)
nvec2flexible=Array{Float64,1}(0)
qvecflexible=Array{Float64,1}(0)
for eps=.5:.01:1
epsilon=eps;
r=nlsolve(eqflexiblehours!, [ .1; .1; 1; 1; .05])
push!(nvec1flexible,r.zero[1])
push!(nvec2flexible,r.zero[2])
push!(hvec1flexible,r.zero[3])
push!(hvec2flexible,r.zero[4])
push!(qvecflexible,r.zero[5])
end
nvec1fixed=Array{Float64,1}(0)
nvec2fixed=Array{Float64,1}(0)
qvecfixed=Array{Float64,1}(0)
for eps=.5:.01:1
epsilon=eps;
hbar=hvec1flexible[end];
r=nlsolve(eqfixedhours!, [ .1; .1; .05])
push!(nvec1fixed,r.zero[1])
push!(nvec2fixed,r.zero[2])
push!(qvecfixed,r.zero[3])
end
In [11]:
fig, ax = subplots()
ax[:plot](.5:.01:1,nvec1flexible./nvec1flexible[end], linewidth=2, color="red", alpha=0.9, label="Sector 1, flexible hours")
ax[:plot](.5:.01:1,nvec2flexible./nvec2flexible[end], linewidth=2, color="blue", alpha=0.9, label="Sector 2, flexible hours")
ax[:legend](loc="lower right")
ax[:set_title]("Employment by sector")
Out[11]:
In [12]:
fig, ax = subplots()
ax[:plot](.5:.01:1,(nvec1flexible+nvec2flexible)./(nvec1flexible[end]+nvec2flexible[end]), linewidth=2, color="black", alpha=0.9, label="E, flexible hours")
ax[:legend](loc="lower right")
ax[:set_title]("Employment")
Out[12]:
In [13]:
fig, ax = subplots()
ax[:plot](.5:.01:1,hvec1flexible./hvec1flexible[end], linewidth=2, color="red", alpha=0.9, label="Sector 1, flexible hours")
ax[:plot](.5:.01:1,hvec2flexible./hvec2flexible[end], linewidth=2, color="blue", alpha=0.9, label="Sector 2, flexible hours")
ax[:legend](loc="lower right")
ax[:set_title]("Average Hours by sector")
Out[13]:
In [14]:
fig, ax = subplots()
ax[:plot](.5:.01:1,(Cv./qvecflexible)./(Cv./qvecflexible[end]), linewidth=2, color="black", alpha=0.9, label="vacancy costs")
ax[:legend](loc="lower right")
ax[:set_title]("Vacancy costs, flexible hours")
Out[14]:
In [22]:
fig, ax = subplots()
ax[:plot](.5:.01:1,nvec1flexible./nvec1flexible[end], linewidth=2, color="red", alpha=0.9, label="Sector 1, flex hours")
ax[:plot](.5:.01:1,nvec2flexible./nvec2flexible[end], linewidth=2, color="blue", alpha=0.9, label="Sector 2, flex hours")
ax[:plot](.5:.01:1,nvec1fixed./nvec1fixed[end], linewidth=2, color="red", alpha=.3, label="Sector 1")
ax[:plot](.5:.01:1,nvec2fixed./nvec2fixed[end], linewidth=2, color="blue", alpha=0.3, label="Sector 2")
ax[:legend](loc="lower right")
ax[:set_title]("Employment by sector")
Out[22]:
In [16]:
fig, ax = subplots()
ax[:plot](.5:.01:1,(nvec1flexible+nvec2flexible)./(nvec1flexible[end]+nvec2flexible[end]), linewidth=2, color="red", alpha=0.9, label="flexible hours")
ax[:plot](.5:.01:1,(nvec1fixed+nvec2fixed)./(nvec1fixed[end]+nvec2fixed[end]), linewidth=2, color="blue", alpha=0.9, label="fixed hours")
ax[:legend](loc="lower right")
ax[:set_title]("Employment")
Out[16]:
In [17]:
fig, ax = subplots()
ax[:plot](.1:.01:1,Cv./qvec, linewidth=2, color="black", alpha=0.9, label="flexible hours")
ax[:plot](.1:.01:1,Cv./qvecfix, linewidth=2, color="black", alpha=0.3, label="fixed hours")
ax[:legend](loc="lower right")
ax[:set_title]("hiring costs")
ax[:set_xticks]([.1, .5, 1])
#ax[:set_yticks]([0, .007, .015])
Out[17]:
In [18]:
outputflexible=collect(.5:.01:1).*(nvec1flexible.*hvec1flexible).^alpha +
1*(nvec2flexible.*hvec2flexible).^alpha;
outputfixed=collect(.5:.01:1).*(nvec1fixed.*hbar).^alpha +
1*(nvec2fixed.*hbar).^alpha;
fig, ax = subplots()
ax[:plot](.5:.01:1,log.(outputflexible./outputflexible[end]), linewidth=2, color="red", alpha=0.9, label="flexible hours")
ax[:plot](.5:.01:1,log.(outputfixed./outputfixed[end]), linewidth=2, color="blue", alpha=0.9, label="fixed hours")
ax[:legend](loc="lower right")
ax[:set_title]("Output")
Out[18]:
In [19]:
fig, ax = subplots()
ax[:plot](.5:.01:1,hvec1flexible./hvec1flexible[end], linewidth=2, color="red", alpha=0.9, label="Sector 1, flexible hours")
ax[:plot](.5:.01:1,hvec2flexible./hvec2flexible[end], linewidth=2, color="blue", alpha=0.9, label="Sector 2, flexible hours")
ax[:legend](loc="lower right")
ax[:set_title]("Hours by sector")
Out[19]:
In [20]:
hvec1flexible[1]
Out[20]:
In [21]:
nvec2flexible[1]
Out[21]:
In [ ]: