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

Possible interface for simple fitting #2

Open
TimTaylor opened this issue Sep 3, 2020 · 1 comment
Open

Possible interface for simple fitting #2

TimTaylor opened this issue Sep 3, 2020 · 1 comment

Comments

@TimTaylor
Copy link
Contributor

library(incidence2)
library(incidence2plus)
library(tidyr)

data(ebola_sim_clean, package = "outbreaks")
dat <- ebola_sim_clean$linelist

inci <- incidence(
  dat,
  date_index = date_of_onset,
  interval = "week",
  last_date = "2014-10-05",
  groups = gender
)
#> 3522 observations outside of [2014-04-07, 2014-10-05] were removed.
inci %>% 
  fit(model = "poisson")
#> # A tibble: 2 x 6
#>   gender model  fitted                 r `r-lower` `r-upper`
#>   <fct>  <list> <list>             <dbl>     <dbl>     <dbl>
#> 1 f      <glm>  <tibble [26 × 6]> 0.0249    0.0233    0.0265
#> 2 m      <glm>  <tibble [26 × 6]> 0.0250    0.0234    0.0267
inci %>% 
  fit(model = "poisson") %>% 
  add_doubling()
#> # A tibble: 2 x 9
#>   gender model fitted      r `r-lower` `r-upper` doubling `doubling-lower`
#>   <fct>  <lis> <list>  <dbl>     <dbl>     <dbl>    <dbl>            <dbl>
#> 1 f      <glm> <tibb… 0.0249    0.0233    0.0265     27.9             29.8
#> 2 m      <glm> <tibb… 0.0250    0.0234    0.0267     27.7             29.7
#> # … with 1 more variable: `doubling-upper` <dbl>
inci %>% 
  fit(model = "poisson") %>% 
  plot(color = "white", angle = 45, n_breaks = 4)

Created on 2020-09-03 by the reprex package (v0.3.0)

@thibautjombart
Copy link
Contributor

Very cool!

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