Closed cwhittaker1000 closed 4 months ago
Get started running this with:
# Loading library
library(helios)
# Checking country is present as new argument and can be overridden
model_params <- get_parameters(overrides = list(workplace_distribution_country = "UK"))
model_params$workplace_distribution_country
model_params <- get_parameters()
model_params$workplace_distribution_country
# Checking create variables works with USA and UK
uk_variables <- create_variables(get_parameters(overrides = list(workplace_distribution_country = "UK"))) ## returns error correctly as we don't have data for UK on this
usa_variables <- create_variables(get_parameters(overrides = list(workplace_distribution_country = "USA")))
usa_workplace_id <- usa_variables$variables_list$workplace$get_categories()
usa_workplace_sizes <- vector()
usa_workplaces <- 1:max(as.numeric(usa_variables$variables_list$workplace$get_categories()))
for(i in usa_workplaces) {
usa_workplace_sizes[i] <- usa_variables$variables_list$workplace$get_size_of(as.character(i))
}
hist(usa_workplace_sizes, breaks = 250)
## Checking run_simulation works with it
usa_results <- run_simulation(get_parameters(overrides = list(workplace_distribution_country = "USA"), archetype = "sars_cov_2"))
plot(usa_results$timestep, usa_results$E_new, type = "l")
Comments addressed, and confirm this works with:
# Loading library
library(helios)
# Checking country is present as new argument and can be overridden
model_params <- get_parameters(overrides = list(workplace_distribution_country = "UK"))
model_params$workplace_distribution_country
model_params <- get_parameters()
model_params$workplace_distribution_country
# Checking create variables works with USA and UK
uk_variables <- create_variables(parameters_list = get_parameters(overrides = list(workplace_distribution_country = "USA"))) ## returns error correctly as we don't have data for UK on this
usa_variables <- create_variables(get_parameters(overrides = list(workplace_distribution_country = "USA")))
usa_workplace_id <- usa_variables$variables_list$workplace$get_categories()
usa_workplace_sizes <- vector()
usa_workplaces <- 1:max(as.numeric(usa_variables$variables_list$workplace$get_categories()))
for(i in usa_workplaces) {
usa_workplace_sizes[i] <- usa_variables$variables_list$workplace$get_size_of(as.character(i))
}
barplot(table(usa_workplace_sizes), breaks = 250)
## Checking run_simulation works with it
usa_results <- run_simulation(get_parameters(overrides = list(workplace_distribution_country = "USA"), archetype = "sars_cov_2"))
plot(usa_results$timestep, usa_results$E_new, type = "l")
Have also updated everything to match the naming convention/approach we're taking where we just specify the country and ignore parameters passed in unless the country is set to custom
.
As discussed in https://github.com/mrc-ide/helios/issues/83#issuecomment-2180619194 we don't need new data for USA workplaces (what we have currently from Ferguson et al 2006 is fine).
This PR updates
get_parameters()
andcreate_variables()
to accommodate the new pattern we're going to use for generating location sizes in general (and matches that of https://github.com/mrc-ide/helios/pull/97).This new pattern uses two arguments
location_distribution_generation
(which can take either"synthetic"
or"empirical"
) &location_distribution_country
(which for workplaces we only have"USA"
currently).