Error in `eval(code, test_env)`: object 'niph_noise_ha_excel' not found

testthat::test_that("zero effect if exp lower than cutoff |pathway_rr|erf_log_lin|exp_single|iteration_FALSE|", {
sex = c("male", "female", "male", "female"),
exp_lower = data$mean_concentration - 1,
exp_upper = data$mean_concentration + 1,
bhd_lower = data$incidents_per_100_000_per_year/1E5*data$population_at_risk - 1,
bhd_upper = data$incidents_per_100_000_per_year/1E5*data$population_at_risk + 1,
expected = # Results on 2025-06-12; no comparison study
testthat::test_that("detailed result the same |fake_rr|erf_log_lin|exp_single|iteration_FALSE|", {
testthat::test_that("number of rows in detailed results correct |meta_rr|erf_log_lin|exp_single|iteration_FALSE|", {
testthat::test_that("results the same |pathway_rr|erf_function|exp_single|iteration_FALSE|", {
erf_eq_central = # GBD2019 ERF for PM and lower respiratory infections
c(1057) # Results on 10 October 2024 (with cutoff = 5 = data$cut_off_value); no comparison study
c(2263) # Results on 10 October 2024 (with cutoff = 0); no comparison study
c(1052) # Results on 10 October 2024 (with cutoff = 5); no comparison study
erf <- splinefun(data$x, data$y, method="natural")
erf_l <- splinefun(data$x, data$y_l, method="natural")
erf_u <- splinefun(data$x, data$y_u, method="natural")
exp_central = 84.1, # exposure distribution for ozone
bhd_central =  29908, #COPD mortality in Germany 2016
##  RESULT(S) FROM THE COMPARISON ASSESSMENT YOU SELECTED
## ASSESSOR: Susanne Breitner-Busch, LMU Munich
## INPUT DATA DETAILS: Modelled ozone exposure, real COPD mortality data from Germany, 2016
testthat::test_that("results the same |fake_rr|erf_lin_log|exp_single|iteration_FALSE|", {
0.927071 # Results on 08 August 2024 (ChatGPT); no comparison study
testthat::test_that("results the same |fake_rr|erf_log_log|exp_single|iteration_FALSE|", {
0.936215963 # Results on 08 August 2024 (ChatGPT); no comparison study
testthat::test_that("results the same |fake_rr|erf_log_lin|exp_single|iteration_TRUE|", {
c(48.2825, 84.9003) # Results on 30 April 2025; no comparison study
exp_central = runif_with_seed(1E2, 8.0, 9.0, 1),
bhd_central = runif_with_seed(1E2, 25000, 35000, 1),
c(317577, 122363, 497741) # Results on 30 April 2025; no comparison study
## IF APPLICABLE: LOAD INPUT DATA BEFORE RUNNING THE FUNCTION
## ASSESSMENT DETAILS: All-cause mortality attributable to PM2.5, by census tract (iteration)
## INPUT DATA DETAILS: Modelled exposure, real mortality data from Belgium, 2021
## ASSESSMENT DETAILS: All-cause mortality attributable to PM2.5, by census tract (iteration) WITH CUTOFF
exp_central = c(82.6,88.7,84.1), # exposure distribution for ozone
bhd_central =  c(27001,31064,29908), #COPD mortality in Germany 2016
testthat::test_that("results the same |fake_rr|erf_lin_log|exp_single|iteration_TRUE|", {
c(0.927071, 0.927071) # Results on 08 August 2024 (ChatGPT); no comparison study
testthat::test_that("results the same |fake_rr|erf_log_log|exp_single|iteration_TRUE|", {
c(0.936215963, 0.936215963) # Results on 06 August 2024 (ChatGPT); no comparison study
testthat::test_that("results the same prevalence-based YLD (duration_central=1) |pathway_rr|erf_log_lin|exp_single|iteration_FALSE|", {
dw_central = 0.5, dw_lower = 0.1, dw_upper = 1,
duration_central = 1, duration_lower = 0.5, duration_upper = 10
c(525, 277, 768) # Result on 16 May 2024; no comparison study
testthat::test_that("results the same incidence-based YLD (duration_central > 1) |pathway_rr|erf_log_lin|exp_single|iteration_FALSE|", {
duration_central = 5, duration_lower = 2, duration_upper = 10
testthat::test_that("results the same prevalence-based YLD |pathway_rr|erf_log_lin|exp_single|iteration_FALSE|", {
testthat::test_that("detailed results the same prevalence-based YLD |pathway_rr|erf_log_lin|exp_single|iteration_FALSE|", {
)$health_detailed$results_raw$impact |> round(), # 2025-04-02 Round at the end to obtain rounded results
expected = # Result on 2025-06-12; no comparison study
testthat::test_that("results correct with cutoff |pathway_rr|erf_log_lin|exp_dist|iteration_FALSE|", {
info = data.frame(pollutant = "road_noise", outcome = "YLD")
testthat::test_that("results the same no cutoff |pathway_rr|erf_log_lin|exp_dist|iteration_FALSE|", {
29358 # Results on 2025-01-20; no comparison study
exp_central = data$Mean.O3, # exposure distribution for ozone
rr_central = 1.037, #pooled ozone effect estimate of the studies Lim et al. 2019, Kazemiparkouhi et al. 2019, Turner et al. 2016
testthat::test_that("results the same |fake_rr|erf_lin_log|exp_dist|iteration_FALSE|", {
testthat::test_that("results the same |fake_rr|erf_log_log|exp_dist|iteration_FALSE|", {
0.936215963 # Results on 06 August 2024 (ChatGPT); no comparison study
testthat::test_that("results the same no cutoff |pathway_rr|erf_log_lin|exp_dist|iteration_TRUE|", {
exp_central = base::rep(c(5, 6, 7, 8, 9), times = 3),
bhd_central = rep(runif_with_seed(3,1E4,1E5,1), each = 5),
base::round(c(545,  634,  991)) # Results on 2025-06-24; no comparison study
erf <- splinefun(data$x[1:21], data$y[1:21], method="natural")
erf_l <- splinefun(data$x[1:21], data$y_l[1:21], method="natural")
erf_u <- splinefun(data$x[1:21], data$y_u[1:21], method="natural")
bhd_central =  data$bhd, #COPD mortality in Germany 2015 and 2016
testthat::test_that("results the same |fake_rr|erf_lin_log|exp_dist|iteration_TRUE|", {
bhd_central = c(10, 10, 10, 10))$health_main$impact,
testthat::test_that("results the same |fake_rr|erf_log_log|exp_dist|iteration_TRUE|", {
testthat::test_that("results the same mrbrt with cutoff |pathway_rr|erf_function|exp_dist|iteration_FALSE|", {
testthat::test_that("results the same mrbrt no cutoff |pathway_rr|erf_function|exp_dist|iteration_FALSE|", {
testthat::test_that("results the same mrbrt with cutoff |fake_rr|erf_function|exp_dist|iteration_FALSE|", {
c(32) # Results on 19 Dec 2024; no comparison study
testthat::test_that("results the same mrbrt no cutoff |fake_rr|erf_function|exp_dist|iteration_FALSE|", {
c(249) # Results on 2025-01-17; no comparison study
c(249) # Results on 2025-01-17 ; no comparison study
c(32,32,76) # Results on 19 Dec 2024 ; no comparison study
testthat::test_that("results the same |fake_rr|erf_function|exp_dist|iteration_FALSE|", {
c(32,32,76) # Results on 28 May 2025 ; no comparison study
info = data.frame(pollutant = "road_noise", outcome = "highly_annoyance", id = 1:5)
info = data.frame(pollutant = "road_noise", outcome = "highly_annoyance")
)$health_detailed$results_raw |> dplyr::slice_head() |> dplyr::select(impact) |> dplyr::pull() |> base::round(),
info = data.frame(pollutant = "road_noise",
testthat::test_that("no error ar iteration", {
runif_with_seed(1,5E3,1E4,1) * runif_with_seed(5,0,1,1), # total pop * proportion pop exposed
info = data.frame(pollutant = "road_noise", outcome = "highly_annoyance"))
testthat::test_that("detailed results the same fake_ar|erf_formula|exp_dist|iteration_TRUE|", {
expected = # Results on 2025-01-20; no comparison study
## Convert data to long format following Ma-Loma's suggestion in #643
tidyr::pivot_longer( cols = dplyr::starts_with("population_exposed_"), names_to = "region", values_to = "exposed" ) |>
dplyr::mutate(region = base::strsplit(region, "_") |> purrr::map_chr(\(x) x[3]))  |>
dplyr::mutate(regionID = region  |>  base::as.factor()  |>  base::as.numeric())
# geo_id_micro = rep(c("c","a","b"), times = 5),
expected = c(150904, 23328, 174232) # Results from NIPH
# Different number of exposure categories across geo_ids
## Stavanger and Bergen highly annoyance
## Add here input data details: data sources, measured vs. modeled, ...
testthat::test_that("results correct prevalence-based YLD |pathway_ar|erf_formula|exp_dist|iteration_FALSE|", {
base::round() / 2 # With dw_central = 0.5 & duration_central = 1 the expected results are half of those we would obtain without dw & duration arguments
## Using the prop_pop_exp and pop_exp arguments in combination
pop_exp = data$population_exposed_total, # For prop_pop_exp case, this vector is summed in the background to get total pop exposed, which is then combined with prop_pop_exp to get the number exposed per exp category)
testthat::test_that("error if geo_id_macro but no geo_id_micro", {
regexp = "If you do not pass a value for geo_id_micro, you cannot use geo_id_macro."
testthat::test_that("error if rr lower than 0", {
regexp = "The values in the following arguments must be higher than 0: rr_central."
## NOTE 2025-08-08: the two error message tests for log-log and log-lin have been commented out, as with the new ERFs it's no problem to calculate RR's for exp=0 or when exp <= cutoff; once we've settled on these new ERFs remove these error messages
# testthat::test_that("error if cutoff higher than exposure when erf_shape == log_log", {
#   error <- "if the exposure-response function shape is log-log or linear-log then the values of cutoff_central, cutoff_lower and cutoff_upper must be lower than the values of exposure_central, exposure_lower and exposure_upper. please adjust."
#         exp_central = 4, cutoff_central = 5,
#         exp_lower = NULL, cutoff_lower = NULL,
#         exp_upper = NULL, cutoff_upper = NULL,
#         exp_central = 3, cutoff_central = 1,
#         exp_lower = 2, cutoff_lower = 0,
#         exp_upper = 5, cutoff_upper = 7,
# testthat::test_that("error if cutoff higher than exposure when erf_shape == linear_log", {
testthat::test_that("error if dw higher than 1", {
regexp = "The values in the following arguments must not be higher than 1: dw_central.")
testthat::test_that("error if not lower>central>upper", {
regexp = "rr_central must be higher than rr_lower and lower than rr_upper."
testthat::test_that("error if only lower or upper", {
regexp = "Either both, rr_lower and rr_upper, or none of them must entered, but not only one.")
testthat::test_that("error if numeric argument is not numeric", {
regexp = "The following arguments should be numeric: exp_central",
# Use fixed because otherwise the brackets regexp give an error in the test
regexp = "For erf_shape, please, type (between quotation marks) one of these options: linear, log_linear, log_log, linear_log.",
# Use fixed = TRUE because brackets in the message
testthat::test_that("error if sum(prop_pop_exp) higher than 1", {
regexp = "The sum of values in prop_pop_exp cannot be higher than 1 for each geo unit.")
testthat::test_that("error if pop_exp and rr |pathway_rr|erf_log_lin|exp_dist|iteration_FALSE|", {
regexp = "The argument pop_exp is aimed for absolute risk. Use prop_pop_exp instead.")
testthat::test_that("error if prop_pop_exp and ar |pathway_rr|erf_log_lin|exp_dist|iteration_FALSE|", {
regexp = "The argument prop_pop_exp is aimed for relative risk. Use pop_exp instead."
testthat::test_that("error if pop_exp and prop_pop_exp |pathway_rr|erf_log_lin|exp_dist|iteration_FALSE|", {
regexp = "The argument pop_exp is aimed for absolute risk. Use prop_pop_exp instead."
testthat::test_that("error if rr and erf_eq", {
regexp = "The argument rr_central cannot be used together with the argument erf_eq_central (either one or the other but not both).",
testthat::test_that("error if multi geo units but different length of geo-depending arguments", {
regexp = "Not clear what is the maximal length of your arguments: 3, 2. Check: exp_central, geo_id_micro.")
testthat::test_that("error if info has incompatible length |pathway_rr|erf_log_lin|exp_dist|iteration_FALSE|", {
regexp = "All function arguments must have the same length (here 6) or length 1. Check: info.",
testthat::test_that("error if length of exp lower than length of prop pop", {
regexp = "All function arguments must have the same length (here 1) or length 1. Check: prop_pop_exp.",
# To prevent not passed test because of the brackets
testthat::test_that("warning if absolute risk and cutoff", {
regexp = "For absolute risk, the value of cutoff_central is not considered; cutoff_central is defined by the exposure-response function."
regexp = "You entered no value for cutoff_central. Therefore, 0 has been assumed as default. Be aware that this can determine your results.")
testthat::test_that("error if erf_eq is not function or string", {
regexp = "erf_eq_central must be a function or a character string." ,