AngusMcLure / PoolPoweR

Power and sample size calculations for surveys using pool testing (AKA group testing)
GNU General Public License v3.0
0 stars 1 forks source link

Repeated warning for increasing `max_s` #23

Open fredjaya opened 1 year ago

fredjaya commented 1 year ago

When intentionally running:

optimise_sN_prevalence(
    prevalence = 0.01, 
    cost_unit = 5, 
    cost_pool = 10,
    cost_cluster = 20,
    correlation = 0.05,
    max_s = 5
)

The following message is returned:

$s
[1] 5

$cost
[1] 0.1495472

$catch
[1] 10

$N
[1] 2

Warning messages:
1: In optimise_s_prevalence(pool_number = Nopt + 1, prevalence, cost_unit,  :
  Maximum cost effectivness is achieved at or above the maximum size of pools allowed. Consider increasing max_s
2: In optimise_sN_prevalence(prevalence = 0.01, cost_unit = 5, cost_pool = 10,  :
  Maximum cost effectivness is achieved at or above the maximum size of pools allowed. Consider increasing max_s

The same warning is defined twice separately, once in optimise_sN_prevalence() and once in optimise_s_prevalence(). I have tried different parameters and if max_s is reached, the optimise_s_prevalence() warning is thrown at least once, and the sN warning only occasionally.

Options are to:

  1. Find parameters that only throw the optimise_sN_prevalence warning
  2. Change the optimise_sN_prevalence message to make catching the warning easier (i.e. tell apart from the optimise_s_prevalence warning
  3. Remove the sN warning completely

Thoughts, Angus?

fredjaya commented 1 year ago

Possibly useful resources for testing:

https://testthat.r-lib.org/reference/expect_snapshot.html

AngusMcLure commented 1 year ago

Easiest might be to remove the optimise_sN_prevalence() warning entirely. However as optimise_sN_prevalence() calls optimise_s_prevalence() repeatedly, the latter might issue the warning multiple times. This is not ideal --- it would be nicer to just have one warning from optimise_sN_prevalence(). If it's possible to catch the warnings from optimise_s_prevalence() and then use this warning to trigger a single warning for optimise_sN_prevalence that would be kind of neat, but if it's not easy, it's not worth it for now.

So in summary, I suggest taking the easy option (remove the warning from optimise_sN_prevalence()) for now, but leave this issue open as a low-priority enhancement for later.