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

power.R S3 output #36

Closed fredjaya closed 3 weeks ago

fredjaya commented 1 month ago

Hey @AngusMcLure, I have just pushed a draft of what an output class for power_pool() could look like, based on the pretty print for stats::power.prop.test.

Need to fix the way pretty print is triggered (e.g. instead of str()), but this is the current command to get the output below

power_pool(cluster_number = 11, pool_number = 2, pool_size = 10, prevalence_null = 0.01, prevalence_alt = 0.02)
      pool_size = 10
    pool_number = 2
 cluster_number = 50
      prev_null = 0.01
       prev_alt = 0.02
      sig_level = 0.05
      --> power = 0.7617911
    alternative = greater

Could you indicate/suggest:

AngusMcLure commented 1 month ago

I've had a look and think I fixed up the roxygen issue that was preventing the print method from registering properly. I also fixed the issues with pool_strat method documentation while I was at it.

Also responses to your questions:

This is potentially quite a lot of results to display, but I think it makes sense to display these.

One bridge to cross is how to display the pool_strat function in a pretty way. I've created a as.character method for it which just return the call as a character, but this might not be an ideal way to represent it.

Happy to discuss more if there are issues/questions

fredjaya commented 1 month ago

Example print output as discussed:

DIAGNOSTIC TEST
sensitivity = 
specificity = 

   PREVALENCE
   prev_alt = 
  prev_null =
correlation = 

STATISTICAL TEST
  sig_level = 
      power =
alternative = 

SAMPLE DESIGN
  pool size = 
   pool num = 
   clusters = 
total units =
total pools =

Placeholder sentence with the inferred value (e.g. power) and some prose 

pool strat and pool catch when using *_random()

AngusMcLure commented 1 month ago

Just noting that we want to make sure that the output/input names match the output/input names in the pretty print layout. Specifically I am thinking about the _ that are present/absent in some of the above names?

fredjaya commented 1 month ago

Agree! This is what it looks like for power_pool() at the moment:

 DIAGNOSTIC TEST 
    sensitivity = 1
    specificity = 1

 PREVALENCE 
      prev_null = 0.01
       prev_alt = 0.02
    correlation = 0

 STATISTICAL TEST 
      sig_level = 0.05
          power = 0.761791072653377
    alternative = greater

 SAMPLE DESIGN 
      pool_size = 10
    pool_number = 2
 cluster_number = 50
    total_pools = 100
    total_units = 1000

 A perfect diagnostic test with the above parameters has a power of 0.761791072653377

And for an imperfect test:


 DIAGNOSTIC TEST 
    sensitivity = 0.99
    specificity = 0.98

 PREVALENCE 
      prev_null = 0.01
       prev_alt = 0.02
    correlation = 0

 STATISTICAL TEST 
      sig_level = 0.05
          power = 0.669690930981782
    alternative = greater

 SAMPLE DESIGN 
      pool_size = 10
    pool_number = 2
 cluster_number = 50
    total_pools = 100
    total_units = 1000

 An imperfect diagnostic test with the above parameters has a power of 0.669690930981782

Any suggestions/changes before I push?

AngusMcLure commented 1 month ago

Looks great.

Two suggestions:

My guess is that we'll have to iterate on what goes into the summary sentences as we look at the different functions!

fredjaya commented 1 month ago

Agree with the rounding when printing! Would still like to keep "imperfect diagnostic test" for clarity