Time Series

knitr::opts_chunk$set(Warning = FALSE, message = FALSE, echo = FALSE)
library(Covid19Wastewater)
library(dplyr)
library(RcppRoll)

Time Series and Offset Analysis

How to find the offset between wastewater and case data. By offsetting the wastewater and case data 1 day at a time and then finding the highest correlation we can find the offset between the wastewater and case data.

data(Case_data, package = "Covid19Wastewater")
totalcases <- Case_data %>% 
  group_by(date) %>% 
  summarise(sum_case = sum(conf_case)) %>% 
  mutate(conf_case = roll_sum(sum_case,10,align = "right", fill = NA))

data(WasteWater_data, package = "Covid19Wastewater")

data(Covariants_data, package = "Covid19Wastewater")

data(Pop_data, package = "Covid19Wastewater")


WasteWater_data <- WasteWater_data%>%
  left_join(Pop_data)

data(Example_data, package = "Covid19Wastewater")

Output is not normal as only example data is used

One way of finding the offset.

offsetDF <- OffsetDFMaker(10, as.Date("2020-08-01"), as.Date("2023-01-01"), Case_data, WasteWater_data)

OffsetDF_Plot(offsetDF, "All Wisconsin data over all time")

Another way to find the offset.

heatmapcorfunc(Example_data)
heatmapcorfunc(Example_data, 10)

Using found offset can try to see how it changes over time and other factors.

covarstarts <- c(as.Date("2020-08-17"),
                 as.Date("2021-03-29"),
                 as.Date("2021-07-05"),
                 as.Date("2021-12-20"),
                 as.Date("2022-03-28"),
                 as.Date("2022-05-23"),
                 as.Date("2022-07-04"))

covarends <- c(as.Date("2021-01-18"),
               as.Date("2021-05-24"),
               as.Date("2021-12-06"),
               as.Date("2022-03-14"),
               as.Date("2022-05-09"),
               as.Date("2022-06-06"),
               as.Date("2022-11-07"))

covarnames <- c("Robin1",
                "Alpha.V1",
                "Delta",
                "Omicron.21K",
                "Omicron.21L",
                "Omicron.22C",
                "Omicron.22B")


OffsetHeatmap("kendall_offset", 0, WasteWater_data, Case_data, Pop_data,
              covarstarts, covarends, covarnames, "region", TRUE, TRUE)

These functions are used in this analysis:



Try the Covid19Wastewater package in your browser

Any scripts or data that you put into this service are public.

Covid19Wastewater documentation built on Aug. 25, 2023, 1:07 a.m.