You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.Rmd
+71-7Lines changed: 71 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -30,15 +30,79 @@ You can install the development version of epipredict from [GitHub](https://gith
30
30
devtools::install_github("cmu-delphi/epipredict")
31
31
```
32
32
33
-
## Example
33
+
## Documentation
34
+
35
+
You can view documentation for the `main` branch at <https://cmu-delphi.github.io/epipredict>.
36
+
37
+
38
+
## Goals for `epipredict`
39
+
40
+
**We hope to provide:**
41
+
42
+
1. A set of basic, easy-to-use forecasters that work out of the box. You should be able to do a reasonably limited amount of customization on them. (Any serious customization happens with point number 2.) For the basic forecasters, we should provide, at least:
43
+
* Baseline flat-line forecaster
44
+
* Autoregressive forecaster
45
+
* Autoregressive classifier
46
+
2. A framework for creating custom forecasters out of modular components. There are four types of components:
47
+
* Preprocessor: do things to the data before model training
48
+
* Trainer: train a model on data, resulting in a fitted model object
49
+
* Predictor: make predictions, using a fitted model object
50
+
* Postprocessor: do things to the predictions before returning
51
+
52
+
**Target audience:**
53
+
54
+
* Basic. Has data, calls forecaster with default arguments.
55
+
* Intermediate. Wants to examine changes to the arguments, take advantage of built in flexibility.
56
+
* Advanced. Wants to write their own forecasters. Maybe willing to build up from some components that we write.
57
+
58
+
The Advanced user should find their task to be relatively easy (and we'll show them how).
59
+
60
+
**Example:**
61
+
During a quiet period, a user decides they want to first predict whether a surge is about to occur, say using variant information from GISAID. Then for surging locations, they want to train an AR model using past surges in the same location. Everywhere else, they predict a flat line. We should be able to do this in a few lines of code.
62
+
63
+
Delphi's own forecasts have been produced/evaluated in this way for a while now, but the code base is scattered and evolving. We want to consolidate, generalize, and simplify to allow others to benefit as well.
64
+
65
+
The basic framework should allow for something like the following. This would
66
+
feel very familiar to anyone working in `R`+`{tidyverse}`.
34
67
35
-
This is a basic example which shows you how to solve a common problem:
68
+
**Simple linear autoregressive model with scaling (modular)**
36
69
37
-
```{r example}
38
-
library(epipredict)
39
-
## basic example code
70
+
```{r ideal-framework, eval=FALSE}
71
+
my_fcaster = new_epi_predictor() %>%
72
+
add_preprocessor(scaler, var = cases, by = pop) %>%
73
+
add_preprocessor(lagger, var = dv_cli, lags = c(0, 7, 14)) %>%
74
+
add_trainer(lm) %>%
75
+
add_predictor(lm.predict) %>%
76
+
add_postprocessor(scaler, by = 1/pop)
40
77
```
41
78
42
-
## Documentation
79
+
Then you could run this on an `epi_df` with one line.
43
80
44
-
You can view documentation for the `main` branch at <https://cmu-delphi.github.io/epipredict>.
The hypothetical example of first classifying, then fitting different models would also fit into this framework. And this isn't far from our current production models.
86
+
87
+
### Why doesn't this exist
88
+
89
+
Closest neighbor is [`{fable}`](https://fable.tidyverts.org/). It does some of what we want but has a few major downsides:
90
+
91
+
1. Small set of standard Time Series models.
92
+
* Small modifications are hard (e.g. can't "just use" `glmnet` instead of `lm`) in an AR model.
93
+
1. Multi-period forecasting is model-based only.
94
+
* This is "iterative" forecasting, and is very bad in epidemiology.
95
+
* Much better with simple models to use "direct" forecasting.
96
+
1. Confidence bands are model-based only.
97
+
* In epi tasks, these dramatically under-cover.
98
+
1. Layering is not possible/natural
99
+
1. Can't use methods that aren't already implemented.
100
+
101
+
The forecasts we did above can't be produced with `{fable}`.
102
+
103
+
104
+
**However:** The developers behind `{fable}` wrote a package called `{fabletools}` that powers model creation (based on `R6`). We can almost certainly borrow some of that technology to lever up.
105
+
106
+
### What this isn't
107
+
108
+
This is not a framework for SIR models. We intend to create some simple versions, but advanced models---those that use variants, hospitalizations, different types of immunity, age stratification, etc.---cannot be compartmentalized in the same way (though see [pypm](https://pypm.github.io/home/)). These types of models also are better at scenario modeling than short term forecasts unless they are quite complicated.
0 commit comments