Skip to content

Commit

Permalink
power_pool() outputs minimum unit, pool, and site numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusMcLure committed Apr 2, 2024
1 parent 99a56a6 commit 7869d32
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions R/power.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
#'
#'
#' @return The statistical power of the proposed design with regards to
#' comparing prevalence to a threshold (`power_pool()`)
#' comparing prevalence to a threshold (`power_pool()`) or a list with the
#' sample size (number of sites, pools, and units) required to achieve desired
#' power (`sample_size_pool()`)
#' @export
#'
#' @examples
Expand Down Expand Up @@ -186,5 +188,12 @@ sample_size_pool <- function(pool_size, pool_number,
form = form))[1,1]

# Note that the below is correct for either kind of one-sided test, but not for two sided tests
((stats::qnorm(power)/sqrt(unit_fia) + stats::qnorm(1 - sig_level)/sqrt(unit_fi0))/(g(theta0) - g(thetaa)))^2
ssraw <- ((stats::qnorm(power)/sqrt(unit_fia) + stats::qnorm(1 - sig_level)/sqrt(unit_fi0))/(g(theta0) - g(thetaa)))^2

total_sites <- ceiling(ssraw/(pool_number * pool_size))
total_pools <- total_sites * pool_number
total_units <- total_pools * pool_size

return(list(sites = total_sites, pools = total_pools, units = total_units))

}

0 comments on commit 7869d32

Please sign in to comment.