1
+
1
2
<!-- README.md is generated from README.Rmd. Please edit that file -->
2
3
3
4
# epiprocess
@@ -12,26 +13,26 @@ time series analysis and forecasting.
12
13
13
14
` {epiprocess} ` contains:
14
15
15
- - ` epi_df() ` and ` epi_archive() ` , two data frame classes (that work
16
- like a ` {tibble} ` with ` {dplyr} ` verbs) for working with
17
- epidemiological time series data;
18
- - signal processing tools building on these data structures such as
19
- - ` epi_slide() ` for sliding window operations;
20
- - ` epix_slide() ` for sliding window operations on archives;
21
- - ` growth_rate() ` for computing growth rates;
22
- - ` detect_outlr() ` for outlier detection;
23
- - ` epi_cor() ` for computing correlations;
16
+ - ` epi_df() ` and ` epi_archive() ` , two data frame classes (that work
17
+ like a ` {tibble} ` with ` {dplyr} ` verbs) for working with
18
+ epidemiological time series data;
19
+ - signal processing tools building on these data structures such as
20
+ - ` epi_slide() ` for sliding window operations;
21
+ - ` epix_slide() ` for sliding window operations on archives;
22
+ - ` growth_rate() ` for computing growth rates;
23
+ - ` detect_outlr() ` for outlier detection;
24
+ - ` epi_cor() ` for computing correlations;
24
25
25
26
If you are new to this set of tools, you may be interested learning
26
27
through a book format: [ Introduction to Epidemiological
27
28
Forecasting] ( https://cmu-delphi.github.io/delphi-tooling-book/ ) .
28
29
29
30
You may also be interested in:
30
31
31
- - ` {epidatr} ` , for accessing wide range of epidemiological data sets,
32
- including COVID-19 data, flu data, and more.
33
- - ` {rtestim} ` , a package for estimating the time-varying reproduction
34
- number of an epidemic.
32
+ - ` {epidatr} ` , for accessing wide range of epidemiological data sets,
33
+ including COVID-19 data, flu data, and more.
34
+ - ` {rtestim} ` , a package for estimating the time-varying reproduction
35
+ number of an epidemic.
35
36
36
37
This package is provided by the [ Delphi group] ( https://delphi.cmu.edu/ )
37
38
at Carnegie Mellon University.
@@ -40,7 +41,7 @@ at Carnegie Mellon University.
40
41
41
42
To install:
42
43
43
- ``` r
44
+ ``` r
44
45
# Stable version
45
46
pak :: pkg_install(" cmu-delphi/epiprocess@main" )
46
47
@@ -55,7 +56,7 @@ The package is not yet on CRAN.
55
56
Once ` epiprocess ` and ` epidatr ` are installed, you can use the following
56
57
code to get started:
57
58
58
- ``` r
59
+ ``` r
59
60
library(epiprocess )
60
61
library(epidatr )
61
62
library(dplyr )
@@ -66,7 +67,7 @@ Get COVID-19 confirmed cumulative case data from JHU CSSE for
66
67
California, Florida, New York, and Texas, from March 1, 2020 to January
67
68
31, 2022
68
69
69
- ``` r
70
+ ``` r
70
71
df <- pub_covidcast(
71
72
source = " jhu-csse" ,
72
73
signals = " confirmed_cumulative_num" ,
89
90
# > # ℹ 2,802 more rows
90
91
```
91
92
92
- Convert the data to an epi_df object and sort by geo_value and
93
- time_value . You can work with an ` epi_df ` like you can with a
93
+ Convert the data to an epi \_ df object and sort by geo \_ value and
94
+ time \_ value . You can work with an ` epi_df ` like you can with a
94
95
` {tibble} ` by using ` {dplyr} ` verbs
95
96
96
- ``` r
97
+ ``` r
97
98
edf <- df %> %
98
99
as_epi_df() %> %
99
100
arrange_canonical() %> %
103
104
# > An `epi_df` object, 2,808 x 4 with metadata:
104
105
# > * geo_type = state
105
106
# > * time_type = day
106
- # > * as_of = 2024-10-14 16:29:54.397851
107
- # >
107
+ # > * as_of = 2024-10-15 02:26:30.787809
108
+ # >
108
109
# > # A tibble: 2,808 × 4
109
110
# > # Groups: geo_value [4]
110
111
# > geo_value time_value cases_cumulative cases_daily
@@ -119,16 +120,20 @@ edf
119
120
```
120
121
121
122
Compute the 7 day moving average of the confirmed daily cases for each
122
- geo_value
123
+ geo \_ value
123
124
124
- ```` r
125
+ ``` r
125
126
edf <- edf %> %
126
127
group_by(geo_value ) %> %
128
+ epi_slide_mean(cases_daily , .window_size = 7 , na.rm = TRUE ) %> %
129
+ rename(smoothed_cases_daily = slide_value_cases_daily )
130
+ ```
131
+
127
132
Autoplot the confirmed daily cases for each geo\_ value
128
133
129
134
``` r
130
135
edf %> %
131
136
autoplot(smoothed_cases_daily )
132
- ````
137
+ ```
133
138
134
139
<img src =" man/figures/README-unnamed-chunk-7-1.svg " width =" 90% " style =" display : block ; margin : auto ;" />
0 commit comments