grattan / covid19.model.sa2

4 stars 0 forks source link

Workplaces make little difference in outcomes #58

Closed wfmackey closed 4 years ago

wfmackey commented 4 years ago

In the model's current form, workplace settings -- q_workplace, workplaces_open, workplace_size_max -- make no observable difference in outcomes, even when pushed to extremes.


  rebuild_runs <- FALSE
  run_days <- 30
  repeat_times <- 50

  library(tidyverse)
  options(dplyr.summarise.inform = FALSE)
  library(purrr)
  library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
  library(covid19.model.sa2)
  library(fst)
  library(glue)
#> 
#> Attaching package: 'glue'
#> The following object is masked from 'package:dplyr':
#> 
#>     collapse
  library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:data.table':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday, week,
#>     yday, year
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
  library(janitor)
#> 
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#> 
#>     chisq.test, fisher.test
  library(strayr)

  repeat_simulation <- function(.name,
                                .rebuild = rebuild_runs,
                                .repeat = repeat_times, 
                                .days = run_days, 
                                EpiPars = set_epipars(),
                                PolicyPars = set_policypars(),
                                ...) {

    file_path <- glue("output/{.name}.fst")

    if (!.rebuild & file.exists(file_path)) {
      message("Run found; loading")
      return(read_fst(file_path))
    }
    # is true otherwise, so proceed

    # Show epi settings
    message("Using epi parameters:")
    print(EpiPars)

    # Show policy settings
    message("Using policy parameters:")
    print(PolicyPars)

    return_simulation <- function(x, 
                                  to_return = .to_return,
                                  .PolicyPars = PolicyPars,
                                  .EpiPars = EpiPars,
                                  ...) {

      rep_each <- function(x, len) {
        rep(x, each = len / length(x), length.out = len)
      }

      d <- 
        simulate_sa2(days_to_simulate = .days, 
                     returner = 3,
                     PolicyPars = .PolicyPars,
                     EpiPars = .EpiPars,
                     ...)

      # Status
      Status12 <- d[["Status12"]]

      DT <- data.table(N = Status12)
      DT[, day := rep_each(1:.days, .N)]
      DT[, state := rep_each(1:9, .N), by = .(day)]
      DT[, status := rep_each(-2:3, .N), by = .(day, state)]
      DT[, isolated := rep_len(0:1, .N)]
      DT[, runid := x]

      # New infections
      NewInfectionsByState <- d[["NewInfectionsByState"]]

      DT2 <- data.table(new_infections = NewInfectionsByState)
      DT2[, day := rep_each(1:.days, .N)]
      DT2[, state := rep_each(1:9, .N), by = .(day)]

      return(left_join(DT, DT2))

    }

    d <- map_dfr(1:.repeat, return_simulation) %>% 
      mutate(state_code = state,
             state = strayr(state),
             conditions = .name)

    if (!dir.exists("output")) dir.create("output")
    write_fst(d, file_path)

  }

  # Run

  loose_open_workplaces <- 
    repeat_simulation("loose_open_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.2,
                      ),
                      PolicyPars = set_policypars(
                        workplaces_open = 1,
                        workplace_size_max = 2000
                      )
    )
#> Run found; loading

  loose_closed_workplaces <- 
    repeat_simulation("loose_closed_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.2,
                      ),
                      PolicyPars = set_policypars(
                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Run found; loading

  tight_open_workplaces <- 
    repeat_simulation("tight_open_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.001 
                      ),
                      PolicyPars = set_policypars(
                        workplaces_open = 1,
                        workplace_size_max = 200
                      )
    )
#> Run found; loading

  tight_closed_workplaces <- 
    repeat_simulation("tight_closed_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.001
                      ),
                      PolicyPars = set_policypars(
                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Run found; loading

  workplaces <- bind_rows(loose_open_workplaces, 
                          loose_closed_workplaces,
                          tight_open_workplaces,
                          tight_closed_workplaces)

  # Plot
  workplaces %>% 
    filter(status >= 1) %>% 
    group_by(conditions, runid, day) %>% 
    summarise(active = sum(N)) %>% 
    ggplot(aes(day, active, group = runid)) + 
    geom_line() + 
    facet_wrap(vars(conditions))


# End reprex

Created on 2020-06-04 by the reprex package (v0.3.0)

wfmackey commented 4 years ago

Any thoughts on why @HughParsonage ?

HughParsonage commented 4 years ago

It’s hard to see why it would be a problem with the core model itself, though it could be. It could also be an issue with the formation of workplaces (perhaps they are too small?)

Ideas for diagnosis: Turn off contact tracing and school lockdown triggers Bulk up the number of infected at the start

HughParsonage commented 4 years ago

One can also use the Source column in the Statuses list element of a returner = 0 to get a better idea. One issue is that supermarkets dominate infections but I can’t work out which assumption drives that

On Thu, 4 Jun 2020 at 11:50 am, HughParsonage notifications@github.com wrote:

It’s hard to see why it would be a problem with the core model itself, though it could be. It could also be an issue with the formation of workplaces (perhaps they are too small?)

Ideas for diagnosis: Turn off contact tracing and school lockdown triggers Bulk up the number of infected at the start

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grattan/covid19.model.sa2/issues/58#issuecomment-638553029, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB54MDBCLOVX7ZPWIBVCJJDRU34WZANCNFSM4NSFXTBA .

wfmackey commented 4 years ago

It’s hard to see why it would be a problem with the core model itself, though it could be. It could also be an issue with the formation of workplaces (perhaps they are too small?)

as in the workplace sizes from ABS Businesses in Australia are small, so the upper limit from workplace_size_max is somewhat redundant? If so, that's really interesting.

wfmackey commented 4 years ago

Number of colleagues is median ~25, so q_workplace = 0.2 should still have a pretty strong effect:

library(covid19.model.sa2)
d <- simulate_sa2()
hist(d$Statuses$nColleagues)

Created on 2020-06-04 by the reprex package (v0.3.0)

wfmackey commented 4 years ago

One can also use the Source column in the Statuses list element of a returner = 0 to get a better idea. One issue is that supermarkets dominate infections but I can’t work out which assumption drives that

I'll look at this today.

HughParsonage commented 4 years ago

There are a couple of phenomena at play that are a bit counter to my intuition.

First most people work close to home and I’m guessing a plurality work in the same sa2, so if supermarkets do all the infecting within an sa2 then that soaks up a lot of the workplace’s potency

Second most workplaces are small, and while we think of policies around working from home as applying to big offices, perhaps most people’s exposure doesn’t decrease that much

wfmackey commented 4 years ago

Closing supermarkets doesn't change:


  rebuild_runs <- TRUE
  run_days <- 30
  repeat_times <- 5

  library(tidyverse)
  options(dplyr.summarise.inform = FALSE)
  library(purrr)
  library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
  library(covid19.model.sa2)
  library(fst)
  library(glue)
#> 
#> Attaching package: 'glue'
#> The following object is masked from 'package:dplyr':
#> 
#>     collapse
  library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:data.table':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday, week,
#>     yday, year
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
  library(janitor)
#> 
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#> 
#>     chisq.test, fisher.test
  library(strayr)

  repeat_simulation <- function(.name,
                                .rebuild = rebuild_runs,
                                .repeat = repeat_times, 
                                .days = run_days, 
                                EpiPars = set_epipars(),
                                PolicyPars = set_policypars(),
                                ...) {

    file_path <- glue("output/{.name}.fst")

    if (!.rebuild & file.exists(file_path)) {
      message("Run found; loading")
      return(read_fst(file_path))
    }
    # is true otherwise, so proceed

    # Show epi settings
    message("Using epi parameters:")
    print(EpiPars)

    # Show policy settings
    message("Using policy parameters:")
    print(PolicyPars)

    return_simulation <- function(x, 
                                  to_return = .to_return,
                                  .PolicyPars = PolicyPars,
                                  .EpiPars = EpiPars,
                                  ...) {

      rep_each <- function(x, len) {
        rep(x, each = len / length(x), length.out = len)
      }

      d <- 
        simulate_sa2(days_to_simulate = .days, 
                     returner = 3,
                     PolicyPars = .PolicyPars,
                     EpiPars = .EpiPars,
                     ...)

      # Status
      Status12 <- d[["Status12"]]

      DT <- data.table(N = Status12)
      DT[, day := rep_each(1:.days, .N)]
      DT[, state := rep_each(1:9, .N), by = .(day)]
      DT[, status := rep_each(-2:3, .N), by = .(day, state)]
      DT[, isolated := rep_len(0:1, .N)]
      DT[, runid := x]

      # New infections
      NewInfectionsByState <- d[["NewInfectionsByState"]]

      DT2 <- data.table(new_infections = NewInfectionsByState)
      DT2[, day := rep_each(1:.days, .N)]
      DT2[, state := rep_each(1:9, .N), by = .(day)]

      return(left_join(DT, DT2))

    }

    d <- map_dfr(1:.repeat, return_simulation) %>% 
      mutate(state_code = state,
             state = strayr(state),
             conditions = .name)

    if (!dir.exists("output")) dir.create("output")
    write_fst(d, file_path)

  }

  # Run

  loose_open_workplaces <- 
    repeat_simulation("loose_open_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.2,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        workplaces_open = 1,
                        workplace_size_max = 2000
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 0.07
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.2
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] TRUE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] TRUE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 1
#> 
#> $workplace_size_max
#> [1] 2000
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, workplaces_open = 1, 
#>     workplace_size_max = 2000)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  loose_closed_workplaces <- 
    repeat_simulation("loose_closed_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.2,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 0.07
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.2
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] TRUE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] TRUE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 0.5
#> 
#> $workplace_size_max
#> [1] 5
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, workplaces_open = 0.5, 
#>     workplace_size_max = 5)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  tight_open_workplaces <- 
    repeat_simulation("tight_open_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.001 
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        workplaces_open = 1,
                        workplace_size_max = 200
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 0.07
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.001
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] TRUE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] TRUE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 1
#> 
#> $workplace_size_max
#> [1] 200
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, workplaces_open = 1, 
#>     workplace_size_max = 200)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  tight_closed_workplaces <- 
    repeat_simulation("tight_closed_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.001
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 0.07
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.001
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] TRUE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] TRUE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 0.5
#> 
#> $workplace_size_max
#> [1] 5
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, workplaces_open = 0.5, 
#>     workplace_size_max = 5)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  workplaces <- bind_rows(loose_open_workplaces, 
                          loose_closed_workplaces,
                          tight_open_workplaces,
                          tight_closed_workplaces)

  # Plot
  workplaces %>% 
    filter(status >= 1) %>% 
    group_by(conditions, runid, day) %>% 
    summarise(active = sum(N)) %>% 
    ggplot(aes(day, active, group = runid)) + 
    geom_line() + 
    facet_wrap(vars(conditions))


# End reprex

Created on 2020-06-04 by the reprex package (v0.3.0)

HughParsonage commented 4 years ago

That looks like just an absence of new cases

wfmackey commented 4 years ago

Closed everything:


  rebuild_runs <- TRUE
  run_days <- 30
  repeat_times <- 5

  library(tidyverse)
  options(dplyr.summarise.inform = FALSE)
  library(purrr)
  library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
  library(covid19.model.sa2)
  library(fst)
  library(glue)
#> 
#> Attaching package: 'glue'
#> The following object is masked from 'package:dplyr':
#> 
#>     collapse
  library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:data.table':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday, week,
#>     yday, year
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
  library(janitor)
#> 
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#> 
#>     chisq.test, fisher.test
  library(strayr)

  repeat_simulation <- function(.name,
                                .rebuild = rebuild_runs,
                                .repeat = repeat_times, 
                                .days = run_days, 
                                EpiPars = set_epipars(),
                                PolicyPars = set_policypars(),
                                ...) {

    file_path <- glue("output/{.name}.fst")

    if (!.rebuild & file.exists(file_path)) {
      message("Run found; loading")
      return(read_fst(file_path))
    }
    # is true otherwise, so proceed

    # Show epi settings
    message("Using epi parameters:")
    print(EpiPars)

    # Show policy settings
    message("Using policy parameters:")
    print(PolicyPars)

    return_simulation <- function(x, 
                                  to_return = .to_return,
                                  .PolicyPars = PolicyPars,
                                  .EpiPars = EpiPars,
                                  ...) {

      rep_each <- function(x, len) {
        rep(x, each = len / length(x), length.out = len)
      }

      d <- 
        simulate_sa2(days_to_simulate = .days, 
                     returner = 3,
                     PolicyPars = .PolicyPars,
                     EpiPars = .EpiPars,
                     ...)

      # Status
      Status12 <- d[["Status12"]]

      DT <- data.table(N = Status12)
      DT[, day := rep_each(1:.days, .N)]
      DT[, state := rep_each(1:9, .N), by = .(day)]
      DT[, status := rep_each(-2:3, .N), by = .(day, state)]
      DT[, isolated := rep_len(0:1, .N)]
      DT[, runid := x]

      # New infections
      NewInfectionsByState <- d[["NewInfectionsByState"]]

      DT2 <- data.table(new_infections = NewInfectionsByState)
      DT2[, day := rep_each(1:.days, .N)]
      DT2[, state := rep_each(1:9, .N), by = .(day)]

      return(left_join(DT, DT2))

    }

    d <- map_dfr(1:.repeat, return_simulation) %>% 
      mutate(state_code = state,
             state = strayr(state),
             conditions = .name)

    if (!dir.exists("output")) dir.create("output")
    write_fst(d, file_path)

  }

  # Run

  loose_open_workplaces <- 
    repeat_simulation("loose_open_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.5,
                        a_workplace_rate = 1,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = 1,
                        workplace_size_max = 2000
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 1
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.5
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] FALSE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] FALSE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 1
#> 
#> $workplace_size_max
#> [1] 2000
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, schools_open = FALSE, 
#>     do_contact_tracing = FALSE, cafes_open = FALSE, workplaces_open = 1, 
#>     workplace_size_max = 2000, travel_outside_sa2 = FALSE)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  loose_closed_workplaces <- 
    repeat_simulation("loose_closed_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.5,
                        a_workplace_rate = 1,

                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 1
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.5
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] FALSE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] FALSE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 0.5
#> 
#> $workplace_size_max
#> [1] 5
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, schools_open = FALSE, 
#>     do_contact_tracing = FALSE, cafes_open = FALSE, workplaces_open = 0.5, 
#>     workplace_size_max = 5, travel_outside_sa2 = FALSE)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  tight_open_workplaces <- 
    repeat_simulation("tight_open_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.001,
                        a_workplace_rate = 0.01,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = 1,
                        workplace_size_max = 2000
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 0.01
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.001
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] FALSE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] FALSE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 1
#> 
#> $workplace_size_max
#> [1] 2000
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, schools_open = FALSE, 
#>     do_contact_tracing = FALSE, cafes_open = FALSE, workplaces_open = 1, 
#>     workplace_size_max = 2000, travel_outside_sa2 = FALSE)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  tight_closed_workplaces <- 
    repeat_simulation("tight_closed_workplaces",
                      EpiPars = set_epipars(
                        q_workplace = 0.001,
                        a_workplace_rate = 0.01,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Using epi parameters:
#> $CHECKED
#> [1] TRUE
#> 
#> $a_household_rate
#> [1] 0.15
#> 
#> $a_schools_rate
#> [1] 0.07
#> 
#> $a_workplace_rate
#> [1] 0.01
#> 
#> $illness_distribution
#> [1] 1
#> 
#> $illness_mean
#> [1] 15
#> 
#> $illness_sigma
#> [1] 1
#> 
#> $incubation_distribution
#> [1] 1
#> 
#> $incubation_mean
#> [1] 5
#> 
#> $incubation_sigma
#> [1] 0.44
#> 
#> $p_asympto
#> [1] 0.48
#> 
#> $p_critical
#> [1] 0.02
#> 
#> $p_death
#> [1] 0.01
#> 
#> $p_visit_major_event
#> [1] 0.01923077
#> 
#> $q_household
#> [1] 0.05
#> 
#> $q_major_event
#> [1] 2e-04
#> 
#> $q_places
#> [1] 0.002
#> 
#> $q_school
#> [1] 0.0003333333
#> 
#> $q_school_grade
#> [1] 0.002
#> 
#> $q_supermarket
#> [1] 0.002
#> 
#> $q_workplace
#> [1] 0.001
#> 
#> $resistance_threshold
#> [1] 0.4
#> Using policy parameters:
#> $school_lockdown_triggers_exist
#> [1] TRUE
#> 
#> $tests_by_state_was_null
#> [1] TRUE
#> 
#> $yday_start
#> [1] 0
#> 
#> $supermarkets_open
#> [1] FALSE
#> 
#> $schools_open
#> [1] FALSE
#> 
#> $only_Year12
#> [1] FALSE
#> 
#> $school_days_per_wk
#> $school_days_per_wk$AUS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NSW
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$VIC
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$QLD
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$SA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$WA
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$TAS
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$NT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$ACT
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$OTH
#>  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
#> 
#> $school_days_per_wk$week15combns
#> $school_days_per_wk$week15combns[[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    2    3    4    5
#> 
#> $school_days_per_wk$week15combns[[2]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    2    2    2    3    3     4
#> [2,]    2    3    4    5    3    4    5    4    5     5
#> 
#> $school_days_per_wk$week15combns[[3]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,]    1    1    1    1    1    1    2    2    2     3
#> [2,]    2    2    2    3    3    4    3    3    4     4
#> [3,]    3    4    5    4    5    5    4    5    5     5
#> 
#> $school_days_per_wk$week15combns[[4]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    2
#> [2,]    2    2    2    3    3
#> [3,]    3    3    4    4    4
#> [4,]    4    5    5    5    5
#> 
#> $school_days_per_wk$week15combns[[5]]
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5
#> 
#> 
#> $school_days_per_wk$all_full_time
#> [1] TRUE
#> 
#> 
#> $do_contact_tracing
#> [1] FALSE
#> 
#> $contact_tracing_days_before_test
#> [1] 0
#> 
#> $contact_tracing_days_until_result
#> [1] 3
#> 
#> $contact_tracing_only_sympto
#> [1] TRUE
#> 
#> $contact_tracing_success
#> [1] 0.9
#> 
#> $tests_by_state
#>  [1] 30178  9962 12392  1897  2076  2420   906   220   305     0
#> 
#> $max_persons_per_event
#> [1] 5
#> 
#> $n_major_events_weekday
#> [1] 28
#> 
#> $n_major_events_weekend
#> [1] 56
#> 
#> $max_persons_per_supermarket
#> [1] 200
#> 
#> $cafes_open
#> [1] FALSE
#> 
#> $age_based_lockdown
#>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $workplaces_open
#> [1] 0.5
#> 
#> $workplace_size_max
#> [1] 5
#> 
#> $workplace_size_beta
#> [1] 13
#> 
#> $workplace_size_lmu
#> [1] -1
#> 
#> $workplace_size_lsi
#> [1] -1
#> 
#> $travel_outside_sa2
#> [1] FALSE
#> 
#> $lockdown_triggers__schools
#> $lockdown_triggers__schools$AUS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NSW
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$VIC
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$QLD
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$SA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$WA
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$TAS
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$NT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$ACT
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> $lockdown_triggers__schools$OTH
#>                      default_schools_with_any_critical 
#>                                                      1 
#> default_schools_with_any_critical_duration_of_lockdown 
#>                                                     91 
#>                        default_schools_with_infections 
#>                                                      4 
#>   default_schools_with_infections_duration_of_lockdown 
#>                                                     28 
#>                    default_schools_with_infections_geq 
#>                                                      3 
#>                                     do_school_lockdown 
#>                                                      1 
#> 
#> 
#> attr(,"original_call")
#> set_policypars(supermarkets_open = FALSE, schools_open = FALSE, 
#>     do_contact_tracing = FALSE, cafes_open = FALSE, workplaces_open = 0.5, 
#>     workplace_size_max = 5, travel_outside_sa2 = FALSE)
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  workplaces <- bind_rows(loose_open_workplaces, 
                          loose_closed_workplaces,
                          tight_open_workplaces,
                          tight_closed_workplaces)

  # Plot
  workplaces %>% 
    filter(status >= 1) %>% 
    group_by(conditions, runid, day) %>% 
    summarise(active = sum(N)) %>% 
    ggplot(aes(day, active, group = runid)) + 
    geom_line() + 
    facet_wrap(vars(conditions))


# End reprex

Created on 2020-06-04 by the reprex package (v0.3.0)

wfmackey commented 4 years ago

Tweaking some other parameters does give expected results, so I think there is an issue with workplaces specifically:


  rebuild_runs <- TRUE
  run_days <- 30
  repeat_times <- 5

  library(tidyverse)
  options(dplyr.summarise.inform = FALSE)
  library(purrr)
  library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
  library(covid19.model.sa2)
  library(fst)
  library(glue)
#> 
#> Attaching package: 'glue'
#> The following object is masked from 'package:dplyr':
#> 
#>     collapse
  library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:data.table':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday, week,
#>     yday, year
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
  library(janitor)
#> 
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#> 
#>     chisq.test, fisher.test
  library(strayr)

  repeat_simulation <- function(.name,
                                .rebuild = rebuild_runs,
                                .repeat = repeat_times, 
                                .days = run_days, 
                                EpiPars = set_epipars(),
                                PolicyPars = set_policypars(),
                                ...) {

    file_path <- glue("output/{.name}.fst")

    if (!.rebuild & file.exists(file_path)) {
      message("Run found; loading")
      return(read_fst(file_path))
    }
    # is true otherwise, so proceed

    # Show epi settings
    # message("Using epi parameters:")
    # print(EpiPars)

    # Show policy settings
    # message("Using policy parameters:")
    # print(PolicyPars)

    return_simulation <- function(x, 
                                  to_return = .to_return,
                                  .PolicyPars = PolicyPars,
                                  .EpiPars = EpiPars,
                                  ...) {

      rep_each <- function(x, len) {
        rep(x, each = len / length(x), length.out = len)
      }

      d <- 
        simulate_sa2(days_to_simulate = .days, 
                     returner = 3,
                     PolicyPars = .PolicyPars,
                     EpiPars = .EpiPars,
                     ...)

      # Status
      Status12 <- d[["Status12"]]

      DT <- data.table(N = Status12)
      DT[, day := rep_each(1:.days, .N)]
      DT[, state := rep_each(1:9, .N), by = .(day)]
      DT[, status := rep_each(-2:3, .N), by = .(day, state)]
      DT[, isolated := rep_len(0:1, .N)]
      DT[, runid := x]

      # New infections
      NewInfectionsByState <- d[["NewInfectionsByState"]]

      DT2 <- data.table(new_infections = NewInfectionsByState)
      DT2[, day := rep_each(1:.days, .N)]
      DT2[, state := rep_each(1:9, .N), by = .(day)]

      return(left_join(DT, DT2))

    }

    d <- map_dfr(1:.repeat, return_simulation) %>% 
      mutate(state_code = state,
             state = strayr(state),
             conditions = .name)

    if (!dir.exists("output")) dir.create("output")
    write_fst(d, file_path)

  }

  # Run

  loose_open_workplaces <- 
    repeat_simulation("loose_open_workplaces",
                      .first_day = "2020-03-31",
                      EpiPars = set_epipars(
                        q_workplace = 0.5,
                        a_workplace_rate = 1,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = 1,
                        workplace_size_max = 2000
                      )
    )
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  tight_closed_workplaces <- 
    repeat_simulation("tight_closed_workplaces",
                      .first_day = "2020-03-31",
                      EpiPars = set_epipars(
                        q_workplace = 0.001,
                        a_workplace_rate = 0.01,
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = FALSE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  open_supermarkets <- 
    repeat_simulation("open_supermarkets",
                      .first_day = "2020-03-31",
                      EpiPars = set_epipars(
                        q_workplace = 0.001,
                        a_workplace_rate = 0.01,
                        q_supermarket = 0.1
                      ),
                      PolicyPars = set_policypars(
                        supermarkets_open = TRUE,
                        schools_open = FALSE,
                        do_contact_tracing = FALSE,
                        cafes_open = FALSE,
                        travel_outside_sa2 = FALSE,

                        workplaces_open = .5,
                        workplace_size_max = 5
                      )
    )
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")
#> Joining, by = c("day", "state")

  workplaces <- bind_rows(loose_open_workplaces, 
                          tight_closed_workplaces,
                          open_supermarkets)

  # Plot
  workplaces %>% 
    filter(status >= 1) %>% 
    group_by(conditions, runid, day) %>% 
    summarise(active = sum(N)) %>% 
    ggplot(aes(day, active, group = runid)) + 
    geom_line() + 
    facet_wrap(vars(conditions))


# End reprex

Created on 2020-06-04 by the reprex package (v0.3.0)

HughParsonage commented 4 years ago

Nope you're right. int to double roundtrip conversion during a refactor.