diff --git a/R/create.R b/R/create.R index c174b645e..c5e5603d9 100644 --- a/R/create.R +++ b/R/create.R @@ -615,12 +615,15 @@ create_initial_conditions <- function(data) { meanlog = data$ls_meanlog, sdlog = ifelse(data$ls_sdlog > 0, data$ls_sdlog, 0.01) )) - - out$rescaled_rho <- array(data.table::fcase( - out$rescaled_rho > data$ls_max, data$ls_max - 0.001, - out$rescaled_rho < data$ls_min, data$ls_min + 0.001, - default = out$rescaled_rho - )) + if (data$gp_type != 3) { + out$rescaled_rho <- array(data.table::fcase( + out$rescaled_rho > data$ls_max, data$ls_max - 0.001, + out$rescaled_rho < data$ls_min, data$ls_min + 0.001, + default = out$rescaled_rho + )) + }else{ + out$rescaled_rho <- array(numeric(0)) + } out$alpha <- array( truncnorm::rtruncnorm( diff --git a/inst/stan/estimate_infections.stan b/inst/stan/estimate_infections.stan index a1eb5526c..c644e5dae 100644 --- a/inst/stan/estimate_infections.stan +++ b/inst/stan/estimate_infections.stan @@ -213,7 +213,7 @@ generated quantities { vector[fixed ? 0 : 1] rho; profile("generated quantities") { - if (!fixed) { + if (!fixed && gp_type != 3) { vector[noise_terms] x = linspaced_vector(noise_terms, 1, noise_terms); rho[1] = rescaled_rho[1] * sd(x); } diff --git a/tests/testthat/test-estimate_infections.R b/tests/testthat/test-estimate_infections.R index cd17ba4f4..0e36122a1 100644 --- a/tests/testthat/test-estimate_infections.R +++ b/tests/testthat/test-estimate_infections.R @@ -38,6 +38,20 @@ test_that("estimate_infections successfully returns estimates using default sett test_estimate_infections(reported_cases) }) +test_that("estimate_infections successfully returns estimates using a Matern 5/2 kernel", { + skip_on_cran() + test_estimate_infections( + reported_cases, gp = gp_opts(kernel = "matern", matern_order = 5 / 2) + ) +}) + +test_that("estimate_infections successfully returns estimates using a Linear kernel", { + skip_on_cran() + test_estimate_infections( + reported_cases, gp = gp_opts(kernel = "linear") + ) +}) + test_that("estimate_infections successfully returns estimates when passed NA values", { skip_on_cran() reported_cases_na <- data.table::copy(reported_cases) @@ -85,7 +99,6 @@ test_that("estimate_infections successfully returns estimates using a single bre ) }) - test_that("estimate_infections successfully returns estimates using a random walk", { skip_on_cran() test_estimate_infections(reported_cases, gp = NULL, rt = rt_opts(rw = 7))