knitr::opts_chunk$set(echo = FALSE)
library(covid19interventions)
library(shiny)
library(DT)
library(ggplot2)
library(tidyverse)
library(changepoint)
library(shinythemes)
library(DT)
library(knitr)

data(mobility)
data(county_intervention_cases)

data(county_interventions)
data(df_joined)

Overview

Goal

Methodology

Change in Mobility

Changepoint Analysis

Change in Mobility by County

fluidPage(
    sidebarLayout(
          sidebarPanel(
            htmlOutput("state_selector"),
            htmlOutput("county_selector"), width = "5"),
           mainPanel(plotOutput("cpplot"),
                     textOutput("pre_cp"),
                     textOutput("post_cp"),
                     width = 7)))


output$state_selector <- renderUI({
selectInput(
  inputId = "state", 
  label = "State:",
  choices = as.character(unique(df_joined$sub_region_1)),
  selected = "California")
  })

output$county_selector <- renderUI({
  available <- df_joined[df_joined$sub_region_1 == input$state, "sub_region_2"]
  selectInput(
    inputId = "county", 
    label = "County:",
    choices = unique(available),
    selected = "Los Angeles County")
})

  output$cpplot <- renderPlot({
    cp_calc <- df_joined %>% filter(sub_region_1 == input$state & 
                               sub_region_2 == input$county &
                               date < order_date &
                               !is.na(workplace_int)) %>%
    select(workplace_int) %>% 
    as.matrix() %>% 
    as.numeric() %>% 
    cpt.mean(method='AMOC')
    plot(cp_calc, cpt.col='blue', 
       ylab = "Workplace Mobility Change from Baseline (%)",
       xlab = "Days since February 15")
    output$pre_cp <- renderText({paste("Pre Changepoint Mean: ",
                                       round(param.est(cp_calc)$mean[1], 2))})
    output$post_cp <- renderText({paste("Post Changepoint Mean:",
                                        round(param.est(cp_calc)$mean[2]))})

})

Final Interventions Database

knitr::include_graphics("output/database.PNG")

Interventions

county_interventions_cases_sl <- county_intervention_cases %>% 
  select(admin1, SAH_State_Date,cases, cases_2day_before, cases_week_after, cases_2week_after, cases_4week_after) %>% 
  distinct(admin1, SAH_State_Date,cases, cases_2day_before, cases_week_after, cases_2week_after, cases_4week_after)

#as.data.frame(county_interventions_cases_sl)                      
datatable(county_interventions_cases_sl)

Before Interventions

knitr::include_graphics("output/state_before_plot.PNG")

During Interventions

knitr::include_graphics("output/state_during_plot.PNG")

1 Week After Interventions

knitr::include_graphics("output/state_1w_after.PNG")

2 Weeks After Interventions

knitr::include_graphics("output/state_2w_after.PNG")

4 Weeks After Interventions

knitr::include_graphics("output/state_4w_after.PNG")

Rationale

Population vs Intervention Date

knitr::include_graphics("output/000036.png")

Political Party vs State Intervention Date

knitr::include_graphics("output/0000b4.png")

Flattening the Curve

Alaksa State

knitr::include_graphics("output/example3.png")

San Diego County, California

knitr::include_graphics("output/example4.png")

Future Work

Thank you



agroimpacts/covid19interventions documentation built on May 6, 2020, 12:35 a.m.