diff --git a/NEWS.md b/NEWS.md index bf5c176d8..db59c20ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,7 +11,7 @@ - The interface for defining delay distributions has been generalised to also cater for continuous distributions - 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 and the `gp_opts()` function has been updated to allow for the specification of a periodic kernel. By @seabbs in #742 and reviewed by @jamesmbaazam. +- Gaussian processes have been vectorised and the `gp_opts()` function has been updated to allow for the specification of periodic and linear kernels. 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)). 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. diff --git a/man/gp_opts.Rd b/man/gp_opts.Rd index c9fa19063..1a3882c1c 100644 --- a/man/gp_opts.Rd +++ b/man/gp_opts.Rd @@ -13,7 +13,7 @@ gp_opts( ls_max = 60, alpha_mean = 0, alpha_sd = 0.01, - kernel = c("matern", "se", "ou", "periodic"), + kernel = c("matern", "se", "ou", "periodic", "linear"), matern_order = 3/2, matern_type, w0 = 1 @@ -32,18 +32,19 @@ approximate Gaussian process. See (Riutort-Mayol et al. 2020 \url{https://arxiv.org/abs/2004.11408}) for advice on updating this default.} \item{ls_mean}{Numeric, defaults to 21 days. The mean of the lognormal -length scale.} +length scale. Not used for linear kernel.} \item{ls_sd}{Numeric, defaults to 7 days. The standard deviation of the log normal length scale. If \code{ls_sd = 0}, inverse-gamma prior on Gaussian process length scale will be used with recommended parameters -\code{inv_gamma(1.499007, 0.057277 * ls_max)}.} +\code{inv_gamma(1.499007, 0.057277 * ls_max)}. Not used for linear kernel.} -\item{ls_min}{Numeric, defaults to 0. The minimum value of the length scale.} +\item{ls_min}{Numeric, defaults to 0. The minimum value of the length scale. +Not used for linear kernel.} \item{ls_max}{Numeric, defaults to 60. The maximum value of the length scale. Updated in \code{\link[=create_gp_data]{create_gp_data()}} to be the length of the input data if -this is smaller.} +this is smaller. Not used for linear kernel.} \item{alpha_mean}{Numeric, defaults to 0. The mean of the magnitude parameter of the Gaussian process kernel. Should be approximately the expected variance @@ -55,7 +56,8 @@ the expected standard deviation of the logged Rt.} \item{kernel}{Character string, the type of kernel required. Currently supporting the squared exponential kernel ("se"), periodic kernel -("periodic"), Ornstein-Uhlenbeck kernel ("ou"), and Matern kernel ("matern").} +("periodic"), Ornstein-Uhlenbeck kernel ("ou"), Matern kernel ("matern"), +and linear kernel ("linear").} \item{matern_order}{Numeric, defaults to 3/2. Order of Matérn Kernel to use. Common choices are 1/2, 3/2, and 5/2. If \code{kernel} is set @@ -82,4 +84,7 @@ gp_opts() # add a custom length scale gp_opts(ls_mean = 4) + +# use linear kernel +gp_opts(kernel = "linear") } diff --git a/tests/testthat/test-create_gp_data.R b/tests/testthat/test-create_gp_data.R index d97b38824..2338e9cb3 100644 --- a/tests/testthat/test-create_gp_data.R +++ b/tests/testthat/test-create_gp_data.R @@ -54,7 +54,5 @@ test_that("create_gp_data correctly handles linear kernel", { data <- list(t = 30, seeding_time = 7, horizon = 7, future_fixed = 0, fixed_from = 0, stationary = 0) linear_gp_opts <- gp_opts(kernel = "linear") gp_data <- create_gp_data(linear_gp_opts, data) - - # Check that gp_type is set to 3 for linear kernel expect_equal(gp_data$gp_type, 3) }) \ No newline at end of file