Skip to content

Commit

Permalink
Add LR_main.jl 0506 Revised
Browse files Browse the repository at this point in the history
  • Loading branch information
KexinChen1999 committed May 6, 2024
1 parent b9ab3f5 commit 6fadfc0
Showing 1 changed file with 79 additions and 22 deletions.
101 changes: 79 additions & 22 deletions src/LR_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ oc_vec[I] .= 1


#Reform implied occupational choice vector
of_vec .= zeros(Int, N)
of_vec = zeros(Int, N)

for ij = 1:minimum(I) .- 1
of_vec[ij] = 1
Expand Down Expand Up @@ -451,39 +451,96 @@ xticklabels = ["<1", "1-2", "2-5", "5-7", "7-10", "10-15", "15+"]

# For the farm model plot
begin
p1 = plot(bar([f_model, farm_pdf_03panel], label=["Model" "2003 Survey Data"], xticks=(1:7, xticklabels), legend=:topright),
colormap=:summer, xlabel="Farm Size Class in Ha", ylabel="Fraction of Farms", size=(600,400))
xlims!(0, 8)
ylims!(0, 0.4)
plot!(p1, title="Farm Size Distribution")
savefig(p1,"Farm Size Distribution.png")
farm_pdf_03panel_matrix = reshape(farm_pdf_03panel, :, 1)
data = hcat(reshape(l_model, :, 1), farm_pdf_03panel_matrix)
xtick_labels = ["<1", "1-2", "2-5", "5-7", "7-10", "10-15", "15+"]
xtick_values = (1:length(xtick_labels), xtick_labels) # Renamed to avoid conflicts

group_size = size(data, 2)
width = 0.35 # Adjust width to fit bars side by side
offsets = [-width/2, width/2] # Position adjustments for each bar
p1 = plot(size=(600, 400), legend=:topright, xticks=xtick_values, ylims=(0, 0.5),
xlabel="Farm Size Class in Ha", ylabel="Fraction of Farms")

# Loop to plot bars with adjusted positions for each group
for i in 1:group_size
bar!(xtick_values[1] .+ offsets[i], data[:, i], label=(i == 1 ? "Model" : "2003 Survey Data"),
bar_width=width, color=:auto)
end

savefig(p1, "LR_main_Farm Size Distribution Across Specified Bins.png")
end

begin
# For the land model plot
p2 = plot(bar([l_model, land_pdf_03panel], label=["Model" "2003 Survey Data"], xticks=(1:7, xticklabels), legend=:topright),
colormap=:summer, xlabel="Farm Size Class in Ha", ylabel="Fraction of Land", size=(600,400))
plot!(p2, title="Land Distribution")
savefig(p2,"Land Distribution.png")
land_pdf_03panel_matrix = reshape(land_pdf_03panel, :, 1)
data = hcat(reshape(l_model, :, 1), land_pdf_03panel_matrix)
xtick_labels = ["<1", "1-2", "2-5", "5-7", "7-10", "10-15", "15+"]
xtick_values = (1:length(xtick_labels), xtick_labels) # Renamed to avoid conflicts

group_size = size(data, 2)
width = 0.35 # Adjust width to fit bars side by side
offsets = [-width/2, width/2] # Position adjustments for each bar
p2 = plot(size=(600, 400), legend=:topright, xticks=xtick_values, ylims=(0, 0.5),
xlabel="Farm Size Class in Ha", ylabel="Fraction of Land")

# Loop to plot bars with adjusted positions for each group
for i in 1:group_size
bar!(xtick_values[1] .+ offsets[i], data[:, i], label=(i == 1 ? "Model" : "2003 Survey Data"),
bar_width=width, color=:auto)
end
savefig(p2, "LR_main_Land Size Distribution Across Specified Bins.png")
end

begin
# For the value added per worker model plot
p3 = plot(bar([VApw_model, VApw_2003data], label=["Model" "2003 Survey Data"], xticks=(1:7, xticklabels), legend=:topright),
colormap=:summer, xlabel="Farm Size Class in Ha", ylabel="Value Added Per Worker (Relative to Average)", size=(600,400))
plot!(p3, title="Value Added Per Worker")
savefig(p3,"Value Added Per Worker.png")
VApw_model_col = reshape(VApw_model, :, 1)
VApw_data_col = reshape(VApw_2003data, :, 1)
data = hcat(VApw_model_col, VApw_data_col)
xtick_labels = ["<1", "1-2", "2-5", "5-7", "7-10", "10-15", "15+"]
xtick_values = (1:length(xtick_labels), xtick_labels) # Renamed to avoid conflicts

group_size = size(data, 2)
width = 0.35 # Adjust width to fit bars side by side
offsets = [-width/2, width/2] # Position adjustments for each bar
p3 = plot(size=(600, 400), legend=:topright, xticks=xtick_values, ylims=(0, 3),
xlabel="Farm Size Class in Ha", ylabel="Value added per worker")

# Loop to plot bars with adjusted positions for each group
for i in 1:group_size
bar!(xtick_values[1] .+ offsets[i], data[:, i], label=(i == 1 ? "Model" : "2003 Survey Data"),
bar_width=width, color=:auto)
end
savefig(p3, "LR_main_Value Added per Worker Distribution Across Specified Bins.png")

end

begin
# For the hired labor per hectare model plot
p4 = plot(bar([HLph_model, HLph_data_03], label=["Model" "2003 Survey Data"], xticks=(1:7, xticklabels), legend=:topright),
colormap=:summer, xlabel="Farm Size Class in Ha", ylabel="Hired Labor Per Hectare (Relative to Average)", size=(600,400))
plot!(p4, title="Hired Labor Per Hectare")
savefig(p4,"Hired Labor Per Hectare.png")
HLph_model_col = reshape(HLph_model, :, 1)
HLph_data_col = reshape(HLph_data_03, :, 1)
data = hcat(HLph_model_col, HLph_data_col)
xtick_labels = ["<1", "1-2", "2-5", "5-7", "7-10", "10-15", "15+"]
xtick_values = (1:length(xtick_labels), xtick_labels) # Renamed to avoid conflicts

group_size = size(data, 2)
width = 0.35 # Adjust width to fit bars side by side
offsets = [-width/2, width/2] # Position adjustments for each bar
p4 = plot(size=(600, 400), legend=:topright, xticks=xtick_values, ylims=(0, 1.5),
xlabel="Farm Size Class in Ha", ylabel="Value added per worker")

# Loop to plot bars with adjusted positions for each group
for i in 1:group_size
bar!(xtick_values[1] .+ offsets[i], data[:, i], label=(i == 1 ? "Model" : "2003 Survey Data"),
bar_width=width, color=:auto)
end
savefig(p4, "LR_main_Hired Labor per Hectare Distribution Across Specified Bins.png")

end







# All labor (hired+operators) by crop
LAB_f = ((sum(of_vec .* nf_vec)) / N) + Nf
LAB_c = ((sum(oc_vec .* nc_vec)) / N) + Nc
Expand Down

0 comments on commit 6fadfc0

Please sign in to comment.