-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathcal_cat_data_routine.Rmd
122 lines (92 loc) · 3.42 KB
/
cal_cat_data_routine.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: "CalCAT Automation"
author: "Modeling Team"
date: "4/30/2020"
output: html_document
---
```{r setup, include=FALSE}
# Copyright 2020, State of California, Department of Public Health
###########################################################
###### #######
###### ######## # ### ### #######
###### # # # # # # # #######
###### # # # # # # # #######
###### ######## # # # # # #######
###### # # # # # # # #######
###### # # # # # # #######
###### ######## ####### # # #######
###### #######
###########################################################
knitr::opts_chunk$set(echo = TRUE)
library(readr)
library(stringr)
library(DBI)
library(odbc)
library(pool)
library(dplyr)
library(tidyr)
library(forcats)
library(lubridate)
library(data.table)
library(jsonlite)
library(knitr)
library(rmarkdown)
library(kableExtra)
library(googlesheets4)
library(RSocrata)
library(forecast)
sapply(list.files("R", full.names = T), source)
###############################################################
############ PARAMTERS TO CHANGE ###############
###############################################################
state_name <- "California"
counties <- get_counties()
state_abbrv <- get_state_abbrv(State = state_name)
fipslist <- make_fips_list()
rand_state <- get_rand_state_number(State = state_name)
state_fips <- get_state_fips(type = "integer")
state_fips_char <- get_state_fips(type = "character")
data_path <- paste0("data/", state_abbrv,"/")
dir.create(data_path)
dir.create(paste0(data_path, "forecasts/"))
dir.create(paste0(data_path, "nowcasts/"))
###############################################################
###############################################################
###############################################################
```
## Nowcast/Forecast Data ####
```{r include = FALSE}
### Pull COVID-19 actuals ###
covid_actuals <- grab_hhs_data(state_abbrv)
fwrite(covid_actuals, paste0(data_path, "covid_actuals.csv"))
```
```{r}
covid_admits_arima <- generate_admits_arima(covid_actuals, state_name)
saveRDS(covid_admits_arima, paste0(data_path, "forecasts/covid_admits_arima.rds"))
```
```{r}
covid_admits_damped_holts <- generate_admits_damped_holts(covid_actuals, state_name)
saveRDS(covid_admits_damped_holts, paste0(data_path, "forecasts/covid_admits_damped_holts.rds"))
```
```{r}
covid_admits_holts <- generate_admits_holts(covid_actuals, state_name)
saveRDS(covid_admits_holts, paste0(data_path, "forecasts/covid_admits_holts.rds"))
```
```{r}
covid_admits_NNETAR <- generate_admits_NNETAR(covid_actuals, state_name)
saveRDS(covid_admits_NNETAR, paste0(data_path, "forecasts/covid_admits_NNETAR.rds"))
```
```{r JRC}
deconvolved_dat <- deconvolve_hosp_to_onset(covid_actuals)
jrc <- generate_jrc(deconvolved_dat, state_name)
saveRDS(jrc, file.path(data_path, "nowcasts/jrc.rds"))
```
```{r Cislaghi}
#deconvolved_dat <- deconvolve_hosp_to_onset(covid_actuals)
cislaghi <- generate_cislaghi(deconvolved_dat, state_name)
saveRDS(cislaghi, file.path(data_path, "nowcasts/cislaghi.rds"))
```
```{r covidestim.org}
covidestim <- grab_covidestim(state_name)
saveRDS(covidestim, file.path(data_path, "nowcasts/covidestim.rds"))
```