date: 2020-04-20 21:08:58 PDT

METHOD

Data are retrieved from the NYTimes Github Repo. This plot is similar to the online chart published by the NYTimes with the addtion that points are encoded for daily estimated case doubling time (the inverse of the growth rate).

Growth is assumed to be exponential. \(t_{double}(t)\) is estimated by:

\[t_{double}(t) = \frac{\int_{0}^{t}cases(t')\; dt'}{cases(t)} \times \log(2)\]

where \(cases(t)\) is the daily reported cases of COVID-19 for a specific location.

Data are reticulated with a spline to reduce noise and derivatives are computed from this smoothed data.

The latest date recorded in the data is 2020-04-19.

HEAT MAP

The maps shows, for counties with > 10 cases, the location, number of current cases, and the calculated growth rate (expressed as doubling time). Shorter doubling times are obviously worse thaan longer doubling times.

As case growth goes to zero, doubling times will tend to infinity. Plots are currently capped at 25 days. Early in the crisis doubling times were on the order of ~ 3 days.

register_google(key = key_Wx)


## cmpute bounding Box

map_cases <- function(data_x = final_plot_data){


  bbox <- make_bbox(lat = lat, lon = lon, data = data_x, f = .1)
  
  c_lat <- (bbox[2] + bbox[4])/2
  c_lon <- (bbox[1] + bbox[3])/2 
  
  
  plot_colors <- c(brewer.pal(n = 11, name = "RdYlGn")[1:9], "#3392B2")
  plot_colors <- plot_colors[-(6:7)]
  
  p <- ggmap(get_googlemap(state_x,
                      zoom = 6 ,scale = 1,
                      maptype ='terrain',
                      color = 'bw', region = "", style = c( 'feature:administrative.country|element:labels|visibility:off', 'feature:administrative.state|element:labels|visibility:on')))
  

  
  q <- p + geom_point(data = data_x %>% filter(date == max(date))%>%arrange(desc(cases))%>%filter(cases>10), aes(x = lon, y = lat,  size = cases, fill = double_time, group = fips), pch=21, alpha = 0.7, color = "grey20") + 
    theme(legend.position="top") +
    xlim(bbox[1], bbox[3]) +
    ylim(bbox[2], bbox[4])+
    scale_size_continuous( breaks=c(8, 64, 512, 4096, 32768), range = c(1, 40))+ theme_bw()+
    scale_fill_gradientn(colors =plot_colors, name = "t(days)") + 
    theme(axis.title.x=element_blank(),
          axis.text.x=element_blank(),
          axis.ticks.x=element_blank(),
          axis.title.y=element_blank(),
          axis.text.y=element_blank(),
          axis.ticks.y=element_blank()) +
    labs(title = str_c('COVID-19 CASE HEAT MAP:', "  ", toupper(state_x)), subtitle=str_c("Data from NYTimes COVID19 Database. Color indicates case-doubling time (in days).","")) +
    annotate(geom="text", x=max(data_x$lon[!is.na(data_x$lon)]), y=min(data_x$lat[!is.na(data_x$lat)]), label=str_c("ww44ss ", today() ), size = 2,
              color="Grey30") #+
  
    # transition_time(date)+
    # ease_aes('linear')
      
    return(q)
}