Skip to content

Commit

Permalink
Updated the vignette, and exported the S3 method
Browse files Browse the repository at this point in the history
  • Loading branch information
telkamp7 committed Oct 30, 2023
1 parent 86f2ca8 commit 066e1d3
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 17 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(predict,aedseo)
S3method(summary,aedseo)
export("%>%")
export(aedseo)
export(fit_growth_rate)
Expand Down
7 changes: 4 additions & 3 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
#' @param object A model object created using the `aedseo` package, typically
#' the result of the `aedseo()` function.
#' @param n_step An integer specifying the number of future time steps for
#' which you want to predict growth rates.
#' @param ... Additional arguement affecting the predictions produced.
#' which you want to predict growth rates. Default is 3.
#' @param ... Additional arguments (not used).
#'
#' @return A tibble S3 object called `aedseo` containing the predicted growth
#' rates, including time, estimated growth rate, lower confidence interval,
#' and upper confidence interval for the specified number of future time steps.
#'
#' @export
#'
#' @importFrom rlang .data
Expand Down Expand Up @@ -49,7 +50,7 @@
#' # Print the prediction
#' print(prediction)
#'
predict.aedseo <- function(object, n_step, ...) {
predict.aedseo <- function(object, n_step = 3, ...) {
# Calculate the prediction
ans <- dplyr::last(object) %>%
dplyr::reframe(
Expand Down
2 changes: 2 additions & 0 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#' @return This function is used for its side effect, which is printing a
#' summary message to the console.
#'
#' @export
#'
#' @examples
#' # Create a tsibble object from sample data
#' tsd_data <- tsd(
Expand Down
12 changes: 6 additions & 6 deletions man/predict.aedseo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions man/summary.aedseo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test_that("Summary prints without errors", {
)

# Capture the output of the summary function
tmp <- capture_output(summary.aedseo(aedseo_poisson))
tmp <- capture_output(summary(aedseo_poisson))

# Verify that the summary printed without errors
expect_true(grepl(pattern = "Summary of aedseo Object", x = tmp))
Expand Down
33 changes: 31 additions & 2 deletions vignettes/aedseo_introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ library(ggplot2)

## Introduction

This vignette ...

The methodology used to detect the onset of seasonal respiratory epidemics can be divided into two essential criteria:

- The local estimate of the exponential growth rate, $r$, is significantly greater than zero.
Expand Down Expand Up @@ -211,5 +209,36 @@ full_data %>%
facet_wrap(facets = vars(name), ncol = 1, scale = "free_y")
```

## The aedseo package implements S3 methods

In this section, we will explore how to use the `predict` and `summary` S3 methods provided by the `aedseo` package. These methods enhance the functionality of your `aedseo` objects, allowing you to make predictions and obtain concise summaries of your analysis results.

### Predicting Growth Rates

The `predict` method for `aedseo` objects allows you to make predictions for future time steps based on the estimated growth rates. Here's how to use it:

```{r}
# Example: Predict growth rates for the next 5 time steps
(prediction <- predict(aedseo_results, n_step = 5))
```

In the example above, we use the predict method to predict growth rates for the next 5 time steps. The n_step argument specifies the number of steps into the future you want to forecast. The resulting prediction object will contain estimates, lower bounds, and upper bounds for each time step.

### Summarizing AEDSEO results

The summary method for aedseo objects provides a concise summary of your automated early detection of seasonal epidemic onset (AEDSEO) analysis. You can use it to retrieve important information about your analysis, including the latest growth warning and the total number of growth warnings:


```{r summary}
summary(aedseo_results)

Check warning on line 237 in vignettes/aedseo_introduction.Rmd

View workflow job for this annotation

GitHub Actions / lint

file=vignettes/aedseo_introduction.Rmd,line=237,col=1,[trailing_blank_lines_linter] Trailing blank lines are superfluous.
```

The summary method generates a summary message that includes details such as the reference time point, growth rate estimates, and the number of growth warnings in the series. It helps you quickly assess the key findings of your analysis.




0 comments on commit 066e1d3

Please sign in to comment.