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

Higher contact rate error #14

Closed
sima-u1418987 opened this issue Apr 6, 2024 · 8 comments · Fixed by #15
Closed

Higher contact rate error #14

sima-u1418987 opened this issue Apr 6, 2024 · 8 comments · Fixed by #15

Comments

@sima-u1418987
Copy link

sima-u1418987 commented Apr 6, 2024

result <- suppressWarnings(suppressMessages(invisible({
  
  library(epiworldR)
  
  library(data.table)
  library(EpiEstim)
  library(dplyr)
  library(ggplot2)
  library(tidyverse)
  library(EpiNow2)
})))


model_seircon=ModelSEIRCONN(name="covid",n=50000,prevalence = 0.001,contact_rate = 20,transmission_rate = 0.5,recovery_rate = 1/7,incubation_days = 3)





run(model_seircon,ndays=50,seed=1912)
#> _________________________________________________________________________
#> |Running the model...
#> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
#> | done.
summary(model_seircon)
#> ________________________________________________________________________________
#> ________________________________________________________________________________
#> SIMULATION STUDY
#> 
#> Name of the model   : Susceptible-Exposed-Infected-Removed (SEIR) (connected)
#> Population size     : 50000
#> Agents' data        : (none)
#> Number of entities  : 0
#> Days (duration)     : 50 (of 50)
#> Number of viruses   : 1
#> Last run elapsed t  : 473.00ms
#> Last run speed      : 5.28 million agents x day / second
#> Rewiring            : off
#> 
#> Global events:
#>  (none)
#> 
#> Virus(es):
#>  - covid (baseline prevalence: 0.10%)
#> 
#> Tool(s):
#>  (none)
#> 
#> Model parameters:
#>  - Avg. Incubation days : 3.0000
#>  - Contact rate         : 20.0000
#>  - Prob. Recovery       : 0.1429
#>  - Prob. Transmission   : 0.5000
#> 
#> Distribution of the population at time 50:
#>   - (0) Susceptible : 49950 -> 0
#>   - (1) Exposed     :    50 -> 0
#>   - (2) Infected    :     0 -> 140
#>   - (3) Recovered   :     0 -> 49860
#> 
#> Transition Probabilities:
#>  - Susceptible  0.60  0.40  0.00  0.00
#>  - Exposed      0.00  0.66  0.34  0.00
#>  - Infected     0.00  0.00  0.86  0.14
#>  - Recovered    0.00  0.00  0.00  1.00



plot(model_seircon)



saver <- make_saver(
  "total_hist",
  "transmission",
  "transition",
  "reproductive",
  "generation"
)
run_multiple(model_seircon,ndays=50,nsim=100,seed=1972,saver=saver)
#> Starting multiple runs (100) using 1 thread(s)
#> _________________________________________________________________________
#> _________________________________________________________________________
#> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
#>  done.


res1 <- run_multiple_get_results(model_seircon)
#> Warning in run_multiple_get_results(model_seircon): When retrieving the saved
#> results, for the case of transmission, there were no observations.
#> Error in attributes(.Data) <- c(attributes(.Data), attrib): all attributes must have names [4 does not]
res1$reproductive
#> Error in eval(expr, envir, enclos): object 'res1' not found
@gvegayon
Copy link
Member

gvegayon commented Apr 7, 2024

Thanks for posting this, @sima-u1418987!

@gvegayon gvegayon transferred this issue from UofUEpiBio/covid19-abm Apr 7, 2024
@gvegayon
Copy link
Member

gvegayon commented Apr 7, 2024

The issue happens when run_multiple is run after run(). It may have something to do with reset.

@sima-u1418987
Copy link
Author

sima-u1418987 commented Apr 7, 2024 via email

@gvegayon gvegayon linked a pull request Apr 7, 2024 that will close this issue
gvegayon added a commit that referenced this issue Apr 7, 2024
* Adding proper way to handle classes

* Adding test for run_multiple after run [skip ci] (see #14)

* Updating version and adding test
@gvegayon
Copy link
Member

gvegayon commented Apr 7, 2024

OK @sima-u1418987. I've fixed the issue. The problem was that agents' states were not being reset. This only happened when you called run() before run_multiple(). The bug is now fixed (agents' states are always reset). You can either try to install the development version following the instructions here. @derekmeyer37, we need to upload the patch soon. I'll send you the targz file.

@sima-u1418987
Copy link
Author

sima-u1418987 commented Apr 8, 2024 via email

@gvegayon
Copy link
Member

gvegayon commented Apr 8, 2024

Did you install the GitHub version? I don't get Rt=0

@derekmeyer37
Copy link
Collaborator

derekmeyer37 commented Apr 8, 2024

@sima-u1418987
You will want to run the github version of the package until the fixed version is available on CRAN. You can do this by installing the package using:
devtools::install_github("UofUEpiBio/epiworldR")

Then, load the epiworldR library using: 
library(epiworldR)

Let us know if this works for you. 

@sima-u1418987
Copy link
Author

sima-u1418987 commented Apr 8, 2024 via email

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

Successfully merging a pull request may close this issue.

3 participants