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: vignettes/advanced.Rmd
+7-11
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,13 @@ vignette: >
9
9
10
10
In this vignette, we discuss how to use the sliding functionality in the
11
11
`epiprocess` package with less common grouping schemes or with computations that
12
-
have advanced output structures.
13
-
The output of a slide computation should either be an atomic value/vector, or a
14
-
data frame. This data frame can have multiple columns, multiple rows, or both.
12
+
have advanced output structures. The output of a slide computation should either
13
+
be an atomic value/vector, or a data frame. This data frame can have multiple
14
+
columns, multiple rows, or both.
15
15
16
16
During basic usage (e.g., when all optional arguments are set to their defaults):
17
17
18
18
*`epi_slide(edf, <computation>, .....)`:
19
-
20
19
* keeps **all** columns of `edf`, adds computed column(s)
21
20
* outputs **one row per row in `edf`** (recycling outputs from
22
21
computations appropriately if there are multiple time series bundled
@@ -26,9 +25,7 @@ During basic usage (e.g., when all optional arguments are set to their defaults)
26
25
`dplyr::arrange(time_value, .by_group = TRUE)`**
27
26
* outputs an **`epi_df`** if the required columns are present, otherwise a
28
27
tibble
29
-
30
28
*`epix_slide(ea, <computation>, .....)`:
31
-
32
29
* keeps **grouping and `time_value`** columns of `ea`, adds computed
33
30
column(s)
34
31
* outputs **any number of rows** (computations are allowed to output any
@@ -40,6 +37,7 @@ During basic usage (e.g., when all optional arguments are set to their defaults)
40
37
* outputs a **tibble**
41
38
42
39
These differences in basic behavior make some common slide operations require less boilerplate:
40
+
43
41
* predictors and targets calculated with `epi_slide` are automatically lined up
44
42
with each other and with the signals from which they were calculated; and
45
43
* computations for an `epix_slide` can output data frames with any number of
@@ -84,13 +82,14 @@ simple synthetic example.
84
82
```{r message = FALSE}
85
83
library(epiprocess)
86
84
library(dplyr)
85
+
set.seed(123)
87
86
88
87
edf <- tibble(
89
88
geo_value = rep(c("ca", "fl", "pa"), each = 3),
90
89
time_value = rep(seq(as.Date("2020-06-01"), as.Date("2020-06-03"), by = "day"), length.out = length(geo_value)),
91
90
x = seq_along(geo_value) + 0.01 * rnorm(length(geo_value)),
92
91
) %>%
93
-
as_epi_df()
92
+
as_epi_df(as_of = as.Date("2024-03-20"))
94
93
95
94
# 2-day trailing average, per geo value
96
95
edf %>%
@@ -338,7 +337,7 @@ library(data.table)
338
337
library(ggplot2)
339
338
theme_set(theme_bw())
340
339
341
-
x <- archive_cases_dv_subset_2$DT %>%
340
+
x <- archive_cases_dv_subset$DT %>%
342
341
filter(geo_value %in% c("ca", "fl")) %>%
343
342
as_epi_archive(compactify = FALSE)
344
343
```
@@ -525,10 +524,7 @@ separate ARX model on each state. As in the archive vignette, we can see a
525
524
difference between version-aware (right column) and -unaware (left column)
526
525
forecasting, as well.
527
526
528
-
529
527
## Attribution
530
528
The `case_rate_7d_av` data used in this document is a modified part of the [COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University](https://github.com/CSSEGISandData/COVID-19) as [republished in the COVIDcast Epidata API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html). This data set is licensed under the terms of the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/) by the Johns Hopkins University on behalf of its Center for Systems Science in Engineering. Copyright Johns Hopkins University 2020.
531
529
532
530
The `percent_cli` data is a modified part of the [COVIDcast Epidata API Doctor Visits data](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/doctor-visits.html). This dataset is licensed under the terms of the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/). Copyright Delphi Research Group at Carnegie Mellon University 2020.
labs(x = "Date", y = "Confirmed cases of Ebola in Sierra Leone")
313
313
```
314
314
315
-
316
-
317
315
## Attribution
318
316
This document contains a dataset that is a modified part of the [COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University](https://github.com/CSSEGISandData/COVID-19) as [republished in the COVIDcast Epidata API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html). This data set is licensed under the terms of the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/) by the Johns Hopkins University on behalf of its Center for Systems Science in Engineering. Copyright Johns Hopkins University 2020.
319
317
320
318
[From the COVIDcast Epidata API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html):
321
319
These signals are taken directly from the JHU CSSE [COVID-19 GitHub repository](https://github.com/CSSEGISandData/COVID-19) without changes.
0 commit comments