Skip to content

Commit

Permalink
Merge pull request #89 from annecori/fix-broken-quantiles
Browse files Browse the repository at this point in the history
Fix broken quantiles (#88)
  • Loading branch information
zkamvar committed Apr 1, 2020
2 parents c41d6e8 + 478ec36 commit ce2ab43
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 73 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

## FIXED
* Fixed incorrect quantiles (issue #88) (#89, @jstockwin)

# EpiEstim 2.2-2

## MISC
Expand Down
16 changes: 8 additions & 8 deletions R/estimate_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,11 @@ estimate_R_func <- function(incid,
na.rm = TRUE
)
median_posterior <- apply(r_sample, 2, median, na.rm = TRUE)
quantile_0.25_posterior <- apply(r_sample, 2, quantile,
quantile_0.75_posterior <- apply(r_sample, 2, quantile,
0.75,
na.rm = TRUE
)
quantile_0.25_posterior <- apply(r_sample, 2, quantile,
quantile_0.95_posterior <- apply(r_sample, 2, quantile,
0.95,
na.rm = TRUE
)
Expand Down Expand Up @@ -587,11 +587,11 @@ estimate_R_func <- function(incid,
na.rm = TRUE
)
median_posterior <- apply(r_sample, 2, median, na.rm = TRUE)
quantile_0.25_posterior <- apply(r_sample, 2, quantile,
quantile_0.75_posterior <- apply(r_sample, 2, quantile,
0.75,
na.rm = TRUE
)
quantile_0.25_posterior <- apply(r_sample, 2, quantile,
quantile_0.95_posterior <- apply(r_sample, 2, quantile,
0.95,
na.rm = TRUE
)
Expand Down Expand Up @@ -636,11 +636,11 @@ estimate_R_func <- function(incid,
shape = a_posterior,
scale = b_posterior, lower.tail = TRUE, log.p = FALSE
)
quantile_0.25_posterior <- qgamma(0.75,
quantile_0.75_posterior <- qgamma(0.75,
shape = a_posterior,
scale = b_posterior, lower.tail = TRUE, log.p = FALSE
)
quantile_0.25_posterior <- qgamma(0.95,
quantile_0.95_posterior <- qgamma(0.95,
shape = a_posterior,
scale = b_posterior, lower.tail = TRUE, log.p = FALSE
)
Expand All @@ -653,8 +653,8 @@ estimate_R_func <- function(incid,
results <- list(R = as.data.frame(cbind(
config$t_start, config$t_end, mean_posterior,
std_posterior, quantile_0.025_posterior, quantile_0.05_posterior,
quantile_0.25_posterior, median_posterior, quantile_0.25_posterior,
quantile_0.25_posterior, quantile_0.975_posterior
quantile_0.25_posterior, median_posterior, quantile_0.75_posterior,
quantile_0.95_posterior, quantile_0.975_posterior
)))

names(results$R) <- c(
Expand Down
Binary file modified tests/expected_output/Example1.rda
Binary file not shown.
Binary file modified tests/expected_output/Example2.rda
Binary file not shown.
Binary file modified tests/expected_output/Example3.rda
Binary file not shown.
Binary file modified tests/expected_output/Example4.rda
Binary file not shown.
84 changes: 42 additions & 42 deletions tests/figs/flu2009-incidence-import.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 23 additions & 21 deletions tests/figs/flu2009-instantaneous-no-legend.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion tests/figs/flu2009-rc.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce2ab43

Please sign in to comment.