-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforecasting_benefits.R
More file actions
33 lines (28 loc) · 925 Bytes
/
forecasting_benefits.R
File metadata and controls
33 lines (28 loc) · 925 Bytes
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
library(purrr)
#Things we need:
#Directly forecast caseloads
#Directly forecast inflows
#Directly forecast outflows
#Directly forecast onflows
#Directly forecast inflow_rates
#Directly forecast outflow_rates
#Directly forecast onflow_rates
#Calculate caseloads from in+out+onflows
#Calculate inflow from population and inflow_rate
#Calculate out/onflow from caseloads and out/onflow rate
#Example workflow:
##Forecast in+out+onflow rates
forecast_rates = function(age_ranges, start_date, end_date, rate="inflow"){
dates = seq(start_date,end_date)
map(age_ranges,~forecast_for_range(.,dates)) %>%
set_names(age_ranges) %>%
as_tibble() %>%
mutate(date = dates) %>%
gather(age_range,inflow_rate,-date) %>%
return()
}
forecast_for_range = function(age_range,dates){
return(rep(0.005,NROW(dates)))
}
##Add population forecasts
##Calculate inflow forecasts from inflow_rate and population forecasts