From 25b4118f27018444d1967ab6ad9bbe6a783820c4 Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Tue, 29 Oct 2024 14:45:03 +0000 Subject: [PATCH 1/3] restore alpha prior SD to 0.05 --- NEWS.md | 3 ++- R/opts.R | 4 ++-- man/gp_opts.Rd | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6ebe2f36e..95c6c28b9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ ## Model changes - A bug in the spectral densities of Matern kernels of order other than 3/2 has been fixed and the vignette updated accordingly. By @sbfnk in #835 and reviewed by @seabbs. +- Changed the prior on the (square root of the) magnitude alpha of the Gaussian Process back to HalfNormal(0, 0.05) based on user feedback of unexpected results. By @sbfnk in #PR and reviewed by. ## Package changes @@ -25,7 +26,7 @@ A release that introduces model improvements to the Gaussian Process models, alo - When defining probability distributions these can now be truncated using the `tolerance` argument - Ornstein-Uhlenbeck and 5 / 2 Matérn kernels have been added. By @sbfnk in #741 and reviewed by @seabbs. - Gaussian processes have been vectorised, leading to some speed gains 🚀 , and the `gp_opts()` function has gained three more options, "periodic", "ou", and "se", to specify periodic and linear kernels respectively. By @seabbs in #742 and reviewed by @jamesmbaazam. -- Prior predictive checks have been used to update the following priors: the prior on the magnitude of the Gaussian process (from HalfNormal(0, 1) to HalfNormal(0, 0.1)), and the prior on the overdispersion (from 1 / HalfNormal(0, 1)^2 to 1 / HalfNormal(0, 0.25)). In the user-facing API, this is a change in default values of the `sd` of `phi` in `obs_opts()` from 1 to 0.25. By @seabbs in #742 and reviewed by @jamesmbaazam. +- Prior predictive checks have been used to update the following priors: the prior on the magnitude of the Gaussian process (from HalfNormal(0, 0.05)^2 to HalfNormal(0, 0.01)^2), and the prior on the overdispersion (from 1 / HalfNormal(0, 1)^2 to 1 / HalfNormal(0, 0.25)). In the user-facing API, this is a change in default values of the `sd` of `phi` in `obs_opts()` from 1 to 0.25. By @seabbs in #742 and reviewed by @jamesmbaazam. - The default stan control options have been updated from `list(adapt_delta = 0.95, max_treedepth = 15)` to `list(adapt_delta = 0.9, max_treedepth = 12)` due to improved performance and to reduce the runtime of the default parameterisations. By @seabbs in #742 and reviewed by @jamesmbaazam. - Initialisation has been simplified by sampling directly from the priors, where possible, rather than from a constrained space. By @seabbs in #742 and reviewed by @jamesmbaazam. - Unnecessary normalisation of delay priors has been removed. By @seabbs in #742 and reviewed by @jamesmbaazam. diff --git a/R/opts.R b/R/opts.R index fa4592e40..05ababa53 100644 --- a/R/opts.R +++ b/R/opts.R @@ -458,7 +458,7 @@ backcalc_opts <- function(prior = c("reports", "none", "infections"), #' deviation of the Gaussian process (logged Rt in case of the renewal model, #' logged infections in case of the nonmechanistic model). #' -#' @param alpha_sd Numeric, defaults to 0.1. The standard deviation of the +#' @param alpha_sd Numeric, defaults to 0.05. The standard deviation of the #' magnitude parameter of the Gaussian process kernel. Can be tuned to adjust #' how far alpha is allowed to deviate form its prior mean (`alpha_mean`). #' @@ -509,7 +509,7 @@ gp_opts <- function(basis_prop = 0.2, ls_min = 0, ls_max = 60, alpha_mean = 0, - alpha_sd = 0.01, + alpha_sd = 0.05, kernel = c("matern", "se", "ou", "periodic"), matern_order = 3 / 2, matern_type, diff --git a/man/gp_opts.Rd b/man/gp_opts.Rd index 984baee1f..af331312d 100644 --- a/man/gp_opts.Rd +++ b/man/gp_opts.Rd @@ -12,7 +12,7 @@ gp_opts( ls_min = 0, ls_max = 60, alpha_mean = 0, - alpha_sd = 0.01, + alpha_sd = 0.05, kernel = c("matern", "se", "ou", "periodic"), matern_order = 3/2, matern_type, @@ -50,7 +50,7 @@ of the Gaussian process kernel. Should be approximately the expected standard deviation of the Gaussian process (logged Rt in case of the renewal model, logged infections in case of the nonmechanistic model).} -\item{alpha_sd}{Numeric, defaults to 0.1. The standard deviation of the +\item{alpha_sd}{Numeric, defaults to 0.05. The standard deviation of the magnitude parameter of the Gaussian process kernel. Can be tuned to adjust how far alpha is allowed to deviate form its prior mean (\code{alpha_mean}).} From e17f85bbdb483a4105edcdfca046f552e5852add Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Tue, 29 Oct 2024 16:00:33 +0000 Subject: [PATCH 2/3] update test --- tests/testthat/test-create_gp_data.R | 2 +- tests/testthat/test-gp_opts.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-create_gp_data.R b/tests/testthat/test-create_gp_data.R index b1f7cc765..81cd895d6 100644 --- a/tests/testthat/test-create_gp_data.R +++ b/tests/testthat/test-create_gp_data.R @@ -11,7 +11,7 @@ test_that("create_gp_data returns correct default values when GP is disabled", { expect_equal(gp_data$ls_sdlog, convert_to_logsd(21, 7)) expect_equal(gp_data$ls_min, 0) expect_equal(gp_data$ls_max, 3.54, tolerance = 0.01) - expect_equal(gp_data$alpha_sd, 0.01) + expect_equal(gp_data$alpha_sd, 0.05) expect_equal(gp_data$gp_type, 2) # Default to Matern expect_equal(gp_data$nu, 3 / 2) expect_equal(gp_data$w0, 1.0) diff --git a/tests/testthat/test-gp_opts.R b/tests/testthat/test-gp_opts.R index cd848b75c..b34a25952 100644 --- a/tests/testthat/test-gp_opts.R +++ b/tests/testthat/test-gp_opts.R @@ -6,7 +6,7 @@ test_that("gp_opts returns correct default values", { expect_equal(gp$ls_sd, 7) expect_equal(gp$ls_min, 0) expect_equal(gp$ls_max, 60) - expect_equal(gp$alpha_sd, 0.01) + expect_equal(gp$alpha_sd, 0.05) expect_equal(gp$kernel, "matern") expect_equal(gp$matern_order, 3 / 2) expect_equal(gp$w0, 1.0) From b98d6083b5056245dfc5c74a111b300aaf164a6a Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Wed, 30 Oct 2024 14:44:57 +0000 Subject: [PATCH 3/3] add reviewer and PR number Co-authored-by: James Azam --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 95c6c28b9..81fb8f991 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ ## Model changes - A bug in the spectral densities of Matern kernels of order other than 3/2 has been fixed and the vignette updated accordingly. By @sbfnk in #835 and reviewed by @seabbs. -- Changed the prior on the (square root of the) magnitude alpha of the Gaussian Process back to HalfNormal(0, 0.05) based on user feedback of unexpected results. By @sbfnk in #PR and reviewed by. +- Changed the prior on the (square root of the) magnitude alpha of the Gaussian Process back to HalfNormal(0, 0.05) based on user feedback of unexpected results. By @sbfnk in #840 and reviewed by @jamesmbaazam. ## Package changes