Skip to content

Commit

Permalink
Wrote some instructions for applying the algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
telkamp7 committed Oct 19, 2023
1 parent 2e101a5 commit 0a4f288
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions vignettes/aedseo_introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,25 @@ sim_data %>%

## Applying the algorithm

In the following section, the application of the algorithm to the simulated data is outlined. The first step is to transform the simulated data into a `tsibble` object using the `tsd()` function.

```{r}
# Construct a 'tsibble' object with the time series data
tsd_data <- tsd(
observed = simulation$simulation,
time = dates,
time_interval = "week"
)
```

Next, the time series data object is passed to the `aedseo()` function. Here, a window width of $k=5$ is specified, meaning that a total of 5 weeks is used in the local estimate of the exponential growth rate. Additionally, a 95\% confidence interval is specified. Finally, the exponential growth rate is estimated using quasi-Poisson regression to account for overdispersion in the data.

```{r}
# Apply the 'aedseo' algorithm
aedseo_results <- aedseo(tsd = tsd_data, k = 5, level = 0.95, family = "quasipoisson")
# Visualize the growth rate
aedseo_results %>%
ggplot(mapping = aes(x = reference_time, y = growth_rate)) +
geom_line() +
geom_ribbon(mapping = aes(ymin = lower_growth_rate, ymax = upper_growth_rate), alpha = 0.3) +
geom_hline(yintercept = 0, linetype = "dashed") +
scale_x_yearweek()
```

In the figure below, the observed values from the simulations is visualized alongside the local estimate of the growth rate and its corresponding 95\% confidence interval.


```{r}
Expand Down

0 comments on commit 0a4f288

Please sign in to comment.