1 of 27

Leveraging data to support local government and nonprofit partners in COVID-19 response

5/20/20

Derek Ouyang, Lecturer

Stanford Future Bay Initiative

Future Bay Initiative

2 of 27

[Content omitted]

3 of 27

  • tigris, tidyverse: basic manipulation of Safegraph data
  • flexdashboard: provides most of the architecture for the dashboard, based on Shiny
  • leaflet: customizable maps, reactive to Shiny
  • plotly: customizable plots, reactive to Shiny

scc_blockgroups <-� block_groups("CA","Santa Clara") %>% � st_transform('+proj=longlat +datum=WGS84')

sj_percenthome_bg <-� sj_socialdistancing %>%� mutate(� `% Leaving Home` = � ((1-completely_home_device_count/device_count)*100) %>%

round(1),� date = date_range_start %>% substr(1,10) %>% as.Date()� ) %>%� dplyr::select(� origin_census_block_group,� `% Leaving Home`,� date� ) %>% � left_join(� sj_blockgroups %>% st_set_geometry(NULL), � by ="origin_census_block_group"� )

4 of 27

  • tigris, tidyverse: basic manipulation of Safegraph data
  • flexdashboard: provides most of the architecture for the dashboard, based on Shiny
  • leaflet: customizable maps, reactive to Shiny
  • plotly: customizable plots, reactive to Shiny

Inputs {.sidebar}�---------------------------------------------------------------��```{r}�sliderInput(� "date", � label = "Date:",� min = min(sj_percenthome_bg$date),� max = max(sj_percenthome_bg$date),� value = max(sj_percenthome_bg$date),� timeFormat = "%m/%d"�)�```

5 of 27

  • tigris, tidyverse: basic manipulation of Safegraph data
  • flexdashboard: provides most of the architecture for the dashboard, based on Shiny
  • leaflet: customizable maps, reactive to Shiny
  • plotly: customizable plots, reactive to Shiny

```{r, context="server"}�observeEvent(input$date,{� leafletProxy("map") %>% � addPolygons(� data = sj_percenthome_bg %>% � filter(date == input$date) %>% � left_join(sj_blockgroups) %>%� st_as_sf(),� layerId = block_Ids,� fillColor = ~teal_pal(`% Leaving Home`),� color = "white",� weight = 0.5,� opacity = 0.5,� fillOpacity = 0.7,� label = ~paste0(`% Leaving Home`,"% leaving home"),� highlightOptions = highlightOptions(weight=2.25, opacity=1),� options = pathOptions(pane = "blocks")� )

})

```

6 of 27

  • tigris, tidyverse: basic manipulation of Safegraph data
  • flexdashboard: provides most of the architecture for the dashboard, based on Shiny
  • leaflet: customizable maps, reactive to Shiny
  • plotly: customizable plots, reactive to Shiny

data <-� unique(sj_percenthome_bg$date) %>% � map_dfr(function(specificdate){� sj_percenthome_bg_altered <-� sj_percenthome_bg %>% � filter(date == specificdate)� � data.frame(� date = specificdate,� mean_percenthome = round(mean(sj_percenthome_bg_altered$`� sd_percenthome = round(sd(sj_percenthome_bg_altered$`� )� }) %>% � arrange(date)

7 of 27

8 of 27

9 of 27

[Content omitted]

10 of 27

11 of 27

Normalization approach

Basic procedure:

# Safegraph devices

Census population

# Safegraph visitors

# Safegraph visits

x

x

Estimated true visits

=

# Safegraph visitors

Total for a single POI

Total for a single POI

Total for a single POI

12 of 27

Normalization approach

Basic procedure:

Macro approach

# Safegraph devices

Census population

# Safegraph visitors

# Safegraph visits

x

x

Estimated true visits

=

# Safegraph visitors

Total for a single POI

Total for a single POI

Total for a single POI

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

13 of 27

Normalization approach

Basic procedure:

Macro approach

Micro approach

# Safegraph devices

Census population

# Safegraph visitors

# Safegraph visits

x

x

Estimated true visits

=

# Safegraph visitors

# Safegraph devices

Census population

x

# Safegraph visitors

For a single recorded origin

For a single recorded origin

For a single recorded origin

# visitors from unrecorded origins x ratio for sum of recorded origins

Total for a single POI

Total for a single POI

Total for a single POI

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

14 of 27

Macro approach

Micro approach

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

# Safegraph devices

Census population

x

# Safegraph visitors

For a single recorded origin

For a single recorded origin

For a single recorded origin

# visitors from unrecorded origins x ratio for sum of recorded origins

15 of 27

Macro approach

Micro approach

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

# Safegraph devices

Census population

x

# Safegraph visitors

For a single recorded origin

For a single recorded origin

For a single recorded origin

# visitors from unrecorded origins x ratio for sum of recorded origins

Single ratio is 35.5

16 of 27

Macro approach

Micro approach

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

17 of 27

Macro approach

Micro approach

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

“Tidying” by recorded origins; last NA row is for remaining “unrecorded” origins

18 of 27

Macro approach

Micro approach

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

Per Safegraph schema, a raw visitor count of “4” could mean 2, 3, or 4. We propagate upper and lower bounds to results

19 of 27

Macro approach

Micro approach

# Safegraph devices

Census population

x

# Safegraph visitors

Sum for all Bay Area block groups

Sum for all Bay Area block groups

Total for a single POI

Different ratios for every row (31.5, 26.5, 21.9) based on specific block group of focus

20 of 27

normBG <- function(

patterns,

home_summary,

bay_blockgroups = norm_bay_blockgroups,

ca_pop_blockgroup = norm_ca_pop_blockgroup

){...}

21 of 27

[Content omitted]

22 of 27

Community Characteristics

Movement Behavior

COVID-19

Spread

?

?

Policies

?

?

?

Confounders

Confounders

23 of 27

24 of 27

library(RSelenium)�library(seleniumPipes)��remDr <- remoteDriver(remoteServerAddr ="ipaddresshere", port=4445L)�remDr$open()��remDr$navigate("https://app.powerbigov.us/view?r=eyJrIjoiZTg2MTlhMWQtZWE5OC00ZDI3LWE4NjAtMTU3YWYwZDRlOTNmIiwidCI6IjBhYzMyMDJmLWMzZTktNGY1Ni04MzBkLTAxN2QwOWQxNmIzZiJ9")��webElem <- remDr$findElements(using = "class", value = "column")��cases <-1:length(webElem) %>% � map(function(x){�webElem[[x]]$getElementAttribute("aria-label") %>% as.character()� }) %>% unlist() %>% � as.data.frame()

25 of 27

  • What’s the right measure for disease spread?
  • What’s the right measure from Safegraph?
  • What’s the optimal lag between movement and cases?
  • What key paradigm shifts exist in time?

26 of 27

[Content omitted]

27 of 27

Leveraging data to support local government and nonprofit partners in COVID-19 response

5/20/20

Stanford Future Bay Initiative

Students: Armelle Coutant, Ayoade Balogun, Cameron Tenner, Charlie Hoffs, Chris Leboa, Evan Kanji, Facundo Golinsky, Emma Liu, Isabelle Foster, Jessica de la Paz, Julia Wagenfehr, Laura Davey, Laura Miron, Maeve Givens, Nancy Chang, Samantha Liu, Simone Speizer, Spencer Robinson, Zihan Wei

Mentors: Cansu Culha, Derek Ouyang, Dr. Gabrielle Wong-Parodi, Dr. Jenny Suckale, Jeremy Smith, Jinal Mehta, Lila Mack, Neel Kasmalkar

Future Bay Initiative