cmu-delphi / epiprocess

Tools for basic signal processing in epidemiology
https://cmu-delphi.github.io/epiprocess/
Other
13 stars 8 forks source link

Default `growth_rate` produces weird jumps around low-activity periods #389

Open brookslogan opened 11 months ago

brookslogan commented 11 months ago
library(tidyverse)
library(epidatr)
library(epiprocess)
#> 
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#> 
#>     filter
cce <- covidcast_epidata()
mi_latest <- cce$signals$"hhs:confirmed_admissions_influenza_1d"$call("state","mi","*")
mi_latest %>%
  as_epi_df() %>%
  mutate(gr = growth_rate(time_value, value)) %>%
  ggplot(aes(time_value, gr)) %>%
  `+`(geom_line())
#> Warning: Removed 230 rows containing missing values (`geom_line()`).

Untitled

Created on 2023-12-13 with reprex v2.0.2

brookslogan commented 11 months ago
cowplot::plot_grid(
           mi_latest %>%
           ggplot(aes(time_value, value)) %>%
           `+`(geom_line()),
           mi_latest %>%
           as_epi_df() %>%
           mutate(gr = growth_rate(time_value, value)) %>%
           ggplot(aes(time_value, gr)) %>%
           `+`(geom_line()),
           ncol = 1L,
           align = "v"
         )
#> Warning messages:
#> 1: Removed 156 rows containing missing values (`geom_line()`). 
#> 2: Removed 230 rows containing missing values (`geom_line()`). 

mi_vert