Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Occupancy Figures #111

Open
lrossouw opened this issue May 27, 2020 · 5 comments
Open

Inconsistent Occupancy Figures #111

lrossouw opened this issue May 27, 2020 · 5 comments

Comments

@lrossouw
Copy link

lrossouw commented May 27, 2020

Getting inconsistent occupancy figures when using format_output with and without reduce_age:

r <- run_explicit_SEEIR_model(country = "United Kingdom", replicates = 10)

# check deaths
death_data_1 <-
  format_output(
    r,
    var_select = c("deaths"),
    reduce_age = FALSE
  )
death_data_2 <-
  format_output(
    r,
    var_select = c("deaths"),
    reduce_age = TRUE
  )

deaths_1 <-
  death_data_1 %>% filter(replicate == 5) %>% group_by(t, compartment) %>% summarise(y =
                                                                                       sum(y)) %>% ungroup()
deaths_2 <-
  death_data_2 %>% filter(replicate == 5) %>% group_by(t, compartment) %>% summarise(y =
                                                                                       sum(y)) %>% ungroup()
stopifnot(deaths_1 == deaths_2) #this is fine!

# check occupancy
capacity_data_1 <-
  format_output(
    r,
    var_select = c("ICU_occupancy"),
    reduce_age = FALSE
  )
capacity_data_2 <-
  format_output(
    r,
    var_select = c("ICU_occupancy"),
    reduce_age = TRUE
  )

occupancy_1 <-
  capacity_data_1 %>% filter(replicate == 5) %>% group_by(t, compartment) %>% summarise(y =
                                                                                          sum(y)) %>% ungroup()
occupancy_2 <-
  capacity_data_2 %>% filter(replicate == 5) %>% group_by(t, compartment) %>% summarise(y =
                                                                                          sum(y)) %>% ungroup()
stopifnot(occupancy_1 == occupancy_2) #these are not equal

occupancy_1 %>% filter(t==68) #>12 000
occupancy_2 %>% filter(t==68) #10 353 (matches capacity)

The occupancies at the bottom should both be 10 353.

@lrossouw
Copy link
Author

Same applies to the demand figures.

@OJWatson
Copy link
Collaborator

Hey @lrossouw - thanks for picking this up. That is indeed a bug.

I have checked that when reduce_age = TRUE you do get the correct totals (i.e. it matches the sum from the correct columns in r$output).

Will get working on a patch.

P.S. Thank you for the really clear reproducible example.

@OJWatson
Copy link
Collaborator

Have found where this is. Need to call it a night but note to self that odin_sv will work through each column with reduce_age = FALSE. For multi compartment summaries like this we need to go through each age column at a time first in order for the data.frame creation on line 214 to work.

@lrossouw
Copy link
Author

I was looking to see how squire priortises beds by age group? I.e. if 100 people of various ages need a bed and I have 10 beds free who gets them?

@lrossouw
Copy link
Author

lrossouw commented Jun 2, 2020

Any feedback on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants