Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telkamp7/issue8 #9

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions R/aedseo.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ aedseo <- function(
# Turn the results into an `aedseo` class
ans <- tibble::new_tibble(
x = res,
class = "aedseo" # TODO: #8 Include metadata about the call, so it can
# be passed onto the `summary()` function. @telkamp7
class = "aedseo",
k = k,
level = level,
family = family
)

return(ans)
Expand Down
30 changes: 26 additions & 4 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#' )
#' # Print the summary of the aedseo_results to the console
#' summary(aedseo_results)
# TODO: #8 Incorporate additional metadata about the call to the `aedseo` function.
summary.aedseo <- function(object, ...) {
# Extract the last observation
last_observation <- dplyr::last(object)
Expand All @@ -58,22 +57,45 @@ summary.aedseo <- function(object, ...) {
dplyr::summarise(sum_of_growth_warnings = sum(.data$growth_warning)) %>%
dplyr::pull(sum_of_growth_warnings)

# Extract the attributes from the object
attributes_object <- attributes(object)

# Extract the object k, level, and family
k <- attributes_object$k
level <- attributes_object$level
family <- attributes_object$family

# Extract the lower and upper confidence intervals
lower_confidence_interval <- (1 - level) / 2
upper_confidence_interval <- level + lower_confidence_interval

# Generate the summary message
summary_message <- sprintf(
"Summary of aedseo Object

Called using distributional family:
%s

Window size for growth rate estimation and
calculation of sum of cases:
%d

Reference time point:
%s

Growth rate estimate:
Estimate Lower Upper
%.3f %.3f %.3f
Growth rate estimate at reference time point:
Estimate Lower (%.1f%%) Upper (%.1f%%)
%.3f %.3f %.3f

Total number of growth warnings in the series:
%d
Latest growth warning:
%s",
family,
k,
as.character(reference_time),
lower_confidence_interval * 100,
upper_confidence_interval * 100,
last_observation$growth_rate,
last_observation$lower_growth_rate,
last_observation$upper_growth_rate,
Expand Down
2 changes: 1 addition & 1 deletion vignettes/articles/aedseo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ To accommodate a variety of scenarios encountered in practical applications, the


```{r parameter_combinations}
#TODO: #7 Conduct the simulation study and write the article on the `aedseo`
# TODO: #7 Conduct the simulation study and write the article on the `aedseo`
# package. @telkamp7
parameter_combinations <- as_tibble(expand_grid(
theta = c(3, 4, 5, 6, 7),
Expand Down