Skip to content

Commit

Permalink
update to est_mobility output, init vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesjohnr committed Sep 24, 2024
1 parent d87cf54 commit 5df4161
Show file tree
Hide file tree
Showing 88 changed files with 2,632 additions and 1,993 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ model/
src/
docs/
pkgdown/
^vignettes/articles$
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ Depends:
grDevices,
utils,
methods
Config/Needs/website: rmarkdown
27 changes: 15 additions & 12 deletions R/est_WASH_coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,28 @@ est_WASH_coverage <- function(PATHS) {
print(weights_table)


path1 <- file.path(PATHS$MODEL_INPUT, "WASH_data_weights.csv")
path2 <- file.path(PATHS$DOCS_TABLES, "WASH_data_weights.csv")

write.csv(weights_table, file=path1, row.names = FALSE)
write.csv(weights_table, file=path2, row.names = FALSE)

path <- file.path(PATHS$DOCS_TABLES, "WASH_data_weights.csv")
write.csv(weights_table, file=path, row.names = FALSE)
message("WASH weights table saved here:")
message(path1)
message(path2)
message(path)



param_df <- make_param_df(variable_name = 'theta',
variable_description = 'WASH coverage',
parameter_distribution = 'point',
j = wash_data$iso_code,
parameter_name = 'mean',
parameter_value = wash_data$Weighted_Mean_WASH)

wash_weight_mean <- wash_data[,c("Country", "iso_code", "Weighted_Mean_WASH")]

path1 <- file.path(PATHS$MODEL_INPUT, "WASH_weighted_mean_theta.csv")
path1 <- file.path(PATHS$MODEL_INPUT, "param_theta_WASH.csv")
path2 <- file.path(PATHS$DOCS_TABLES, "WASH_weighted_mean_theta.csv")

write.csv(wash_weight_mean, file=path1, row.names = FALSE)
write.csv(wash_weight_mean, file=path2, row.names = FALSE)
write.csv(param_df, file=path1, row.names = FALSE)

write.csv(wash_data[,c("Country", "iso_code", "Weighted_Mean_WASH")],
file=path2, row.names = FALSE)

message("WASH weighted mean (tau) saved here:")
message(path1)
Expand Down
34 changes: 22 additions & 12 deletions R/est_mobility.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,17 @@ est_mobility <- function(PATHS) {
param_df_point <- make_param_df(
variable_name = "tau", # Assuming 'tau' represents travel probabilities
variable_description = "Country-level travel probabilities",
parameter_distribution = "beta",
i = df_travel_prob$iso_code, # i is set to the iso_code
j = NA, # j is not applicable in this case
t = NA, # t is not applicable in this case
parameter_name = "point",
parameter_distribution = "point",
i = df_travel_prob$iso_code,
parameter_name = "mean",
parameter_value = df_travel_prob$mean
)

param_df_stoch <- make_param_df(
variable_name = "tau", # Assuming 'tau' represents travel probabilities
variable_description = "Country-level travel probabilities",
parameter_distribution = "beta",
i = df_travel_prob$iso_code, # i is set to the iso_code
j = NA, # j is not applicable in this case
t = NA, # t is not applicable in this case
i = df_travel_prob$iso_code,
parameter_name = c(rep("shape1", nrow(df_travel_prob)), rep("shape2", nrow(df_travel_prob))),
parameter_value = c(df_travel_prob$shape1, df_travel_prob$shape2)
)
Expand All @@ -190,12 +186,26 @@ est_mobility <- function(PATHS) {
param_df <- param_df[order(param_df$i),]

utils::write.csv(param_df, file.path(PATHS$MODEL_INPUT, "param_tau_departure.csv"), row.names = FALSE)
utils::write.csv(mod_mobility_summary, file.path(PATHS$MODEL_INPUT, "param_diffusion_model.csv"), row.names = TRUE)

tmp <- melt(pi)

param_df <- make_param_df(
variable_name = "pi", # Assuming 'tau' represents travel probabilities
variable_description = "Probability of travel from i to j",
parameter_distribution = "point",
i = tmp$origin,
j = tmp$destination,
parameter_name = 'mean',
parameter_value = tmp$value
)

utils::write.csv(param_df, file.path(PATHS$MODEL_INPUT, "param_pi_diffusion.csv"), row.names = FALSE)


#utils::write.csv(mod_mobility_summary, file.path(PATHS$MODEL_INPUT, "param_diffusion_model.csv"), row.names = TRUE)

utils::write.csv(df_travel_prob[,c("country", "iso_code", "mean", "sd", "ci_lo", "ci_hi")],
file.path(PATHS$MODEL_INPUT, "pred_tau_departure.csv"), row.names = FALSE)
utils::write.csv(melt(pi), file.path(PATHS$MODEL_INPUT, "pred_pi_diffusion.csv"), row.names = FALSE)
#utils::write.csv(df_travel_prob[,c("country", "iso_code", "mean", "sd", "ci_lo", "ci_hi")],
# file.path(PATHS$MODEL_INPUT, "pred_tau_departure.csv"), row.names = FALSE)


message("Mobility model fitting complete.")
Expand Down
3 changes: 2 additions & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ navbar:
- text: Vignettes
href: articles/index.html
menu:
- text: Project setup
href: articles/Project-setup.html
- text: Running MOSAIC
href: articles/LAUNCH.html
href: articles/Running-MOSAIC.html
right:
- icon: fa-github
href: https://github.com/InstituteforDiseaseModeling/MOSAIC-pkg
Expand Down
169 changes: 169 additions & 0 deletions docs/articles/Project-setup.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5df4161

Please sign in to comment.