Skip to content
Snippets Groups Projects
Commit 786162d3 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

bugfix in ws/rest data loading, new posteriors

parent 80a15389
No related branches found
No related tags found
No related merge requests found
...@@ -72,15 +72,23 @@ const unemployment_matrix = alpha_matrix( ...@@ -72,15 +72,23 @@ const unemployment_matrix = alpha_matrix(
) )
function make_workschool_mixing_matrix() function make_workschool_mixing_matrix()
#all geometric with means given
ws_mixing = map(t->from_mean(t...),[ ws_mixing = map(t->from_mean(t...),[
(Geometric{Float64}, 4.104848) (Geometric{Float64},2.568782) (Geometric{Float64},0.017729) (Geometric{Float64}, 4.104848) (Geometric{Float64},2.568782) (Geometric{Float64},0.017729)
(Geometric{Float64}, 0.975688) (Geometric{Float64},5.057572) (Geometric{Float64},0.021307) (Geometric{Float64}, 0.975688) (Geometric{Float64},5.057572) (Geometric{Float64},0.021307)
(Geometric{Float64},0.001937) (Geometric{Float64},0.00722) (Geometric{Float64}, 0.022134) (Geometric{Float64},0.001937) (Geometric{Float64},0.00722) (Geometric{Float64}, 0.022134)
]) ])
#symmetrize WS mixing with respect to the population proportions in the data
ws_mixing_w_unemployment_symmetrized = symmetrize_means(get_household_data_proportions(),ws_mixing) ws_mixing_w_unemployment_symmetrized = symmetrize_means(get_household_data_proportions(),ws_mixing)
#define a function that adjusts the means of W according to the unemployment_matrix
ws_adjust_mean(W) = (5/7) .* (1 .- unemployment_matrix) ./ ( mean.(W) + (5/7) .* (1 .- unemployment_matrix)) ws_adjust_mean(W) = (5/7) .* (1 .- unemployment_matrix) ./ ( mean.(W) + (5/7) .* (1 .- unemployment_matrix))
#create a zero weighted distribution where the zero-weight is given by the unemployment_matrix, and the non-zero weight is given by ws_mixing, symmetrized, with means adjust upwards
ws_mixing_w_unemployment_symmetrized_weekday_adjusted = ZWDist.(unemployment_matrix,Geometric.(ws_adjust_mean(ws_mixing_w_unemployment_symmetrized))) ws_mixing_w_unemployment_symmetrized_weekday_adjusted = ZWDist.(unemployment_matrix,Geometric.(ws_adjust_mean(ws_mixing_w_unemployment_symmetrized)))
return ws_mixing_w_unemployment_symmetrized_weekday_adjusted return ws_mixing_w_unemployment_symmetrized_weekday_adjusted
end end
...@@ -90,6 +98,7 @@ const initial_rest_mixing_matrix = symmetrize_means(get_household_data_proporti ...@@ -90,6 +98,7 @@ const initial_rest_mixing_matrix = symmetrize_means(get_household_data_proporti
(Geometric{Float64},0.264822) (Geometric{Float64},0.734856) (Geometric{Float64},0.667099) (Geometric{Float64},0.264822) (Geometric{Float64},0.734856) (Geometric{Float64},0.667099)
])) ]))
const initial_workschool_mixing_matrix = make_workschool_mixing_matrix() const initial_workschool_mixing_matrix = make_workschool_mixing_matrix()
@views function ws_sample(age) @views function ws_sample(age)
return rand.(initial_workschool_mixing_matrix[age,:]) * (rand(RNG) < (5/7)) return rand.(initial_workschool_mixing_matrix[age,:]) * (rand(RNG) < (5/7))
end end
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -46,9 +46,9 @@ Runs parameter estimation for the three scenarios, hh, ws, and rest. ...@@ -46,9 +46,9 @@ Runs parameter estimation for the three scenarios, hh, ws, and rest.
""" """
function main() function main()
# do_hh(500) # do_hh(500)
do_ws(500) do_ws(5000)
do_rest(500) do_rest(5000)
# plot_all() plot_all()
end end
""" """
......
...@@ -39,8 +39,8 @@ function get_rest_data() ...@@ -39,8 +39,8 @@ function get_rest_data()
path = "$PACKAGE_FOLDER/network-data/Timeuse/Rest/RData" path = "$PACKAGE_FOLDER/network-data/Timeuse/Rest/RData"
data_table_by_age = map(collect(keys(swap_dict))) do age data_table_by_age = map(collect(keys(swap_dict))) do age
data_table = CSV.File(path*"$age.csv") |> Tables.matrix data_table = CSV.File(path*"$age.csv") |> Tables.matrix
weights = Weights(data_table[:,1]) weights = Weights(data_table[:,2])
durs = data_table[:,2] durs = data_table[:,3]
Symbol(age) => (;durs, weights) Symbol(age) => (;durs, weights)
end end
return (;data_table_by_age...) return (;data_table_by_age...)
...@@ -53,8 +53,8 @@ function get_ws_data() ...@@ -53,8 +53,8 @@ function get_ws_data()
path = "$PACKAGE_FOLDER/network-data/Timeuse/WS/WorkschoolData" path = "$PACKAGE_FOLDER/network-data/Timeuse/WS/WorkschoolData"
data_table_by_age = map(collect(keys(swap_dict))) do age data_table_by_age = map(collect(keys(swap_dict))) do age
data_table = CSV.File(path*"$age.csv") |> Tables.matrix data_table = CSV.File(path*"$age.csv") |> Tables.matrix
weights = Weights(data_table[:,1]) weights = Weights(data_table[:,2])
durs = data_table[:,2] durs = data_table[:,3]
Symbol(age) => (;durs, weights) Symbol(age) => (;durs, weights)
end end
return (;data_table_by_age...) return (;data_table_by_age...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment