Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusMcLure committed Dec 5, 2023
2 parents 9fe54a9 + 4f5de76 commit 1373737
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 377 deletions.
77 changes: 49 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,68 @@ and this project adheres to

### Long-term
- [ ] Establish default values for functions [#11](https://github.com/AngusMcLure/PoolPoweR/issues/11)
- [ ] Create full class system for catch_distribution [#15](https://github.com/AngusMcLure/PoolPoweR/issues/15)

### [v1.0.0]
- CRAN release
- Add pkgdown site #20
- [ ] What is the MVP required for a CRAN release?

### [v0.1.1]
- [ ] Implement new functions

### [v0.1.0]
### [vX]
**Focus:** Package
- [ ] Fix integrand issue
- [ ] Implement codecov.io
- [ ] Refactor functions (i.e. break down into smaller ones for readability)
- [ ] Configure and optimise GHA workflows
- [ ] Fix integrand issue (#21)
- [ ] Implement codecov.io (#5)
- [ ] Refactor functions i.e. break down into smaller ones for readability (#26)
- [ ] Configure and optimise GHA workflows

### [v0.0.3]
### [vX]
**Focus:** Documentation
- [ ] Revise documentation so majority @inheritParams fi_pool
- [ ] Rename interval [#13](https://github.com/AngusMcLure/PoolPoweR/issues/13)
- [ ] Update docs with cluster and non-cluster cases
[#14](https://github.com/AngusMcLure/PoolPoweR/issues/14)
- [ ] Add PoolPoweR-package.R (#18)
- [ ] Move descriptions to details
- [x] Rename real.scale to real_scale

### [v0.0.2] - 2023-12-01
**Focus:** Tests
- [ ] Add helper function for input variable checks
[#2](https://github.com/AngusMcLure/PoolPoweR/issues/2)
- [ ] Throw warnings for some input variable ranges
[#3](https://github.com/AngusMcLure/PoolPoweR/issues/3)
- Note: these parts currently lack test coverage in user-level functions
- [ ] Update unit tests with examples added in
[#11](https://github.com/AngusMcLure/PoolPoweR/issues/11)
- [ ] Add GHA for test coverage
[#5](https://github.com/AngusMcLure/PoolPoweR/issues/5)
- [ ] Add tests for uncovered lines
- [ ] Speed up tests (some slow ones fo fisher_info.R)

## [Released]

### [v0.1.1] - 2023-12-08
- Update tests to pass new additions (#29, #30, #32)
- Add check_rho() to input_check() (#32)
- Document optimise_random_prevalence() arguments #31

## [Available]

### [v0.1.0] - 2023-12-05

Period sampling functions.

#### Added
- `fi_pool_cluster_random()` and `optimise_random_prevalence()` for evaluating
and designing surverys where the number of units caught at each site (or
overall) are random
- Machinery to make the above work (`catch_distributions.R`, `pooling_strategies.R`)

#### Fixed
- Convergence of integrals with `fi_pool_cluster()` introduced by edge cases.

#### Changed
- `fi_pool_cluster()` integration will throw an error with extreme cases.

### [v0.0.2] - 2023-12-05

Test coverage at 96.79%, but still requires considerable revision.

#### Added
- Helper functions for arguments in `check_inputs.R`. Implemented in mainly
user-facing functions: `optimise_s_prevalence()`, `optimise_sN_prevalence()`,
`design_effect()` and `fi_pool_cluster()` (#2)
- Unit tests with reasonable examples from #11.
- `test-coverage` and GHA (#5)

#### Changed
- Error and warning handling for `fi_pool_cluster()` inputs

#### Removed
- Slower `fi_pool_cluster()` unit tests (cases where $s>1$ and $N>1$), these
also had extreme parameters.

### [v0.0.1] MVP!

Expand All @@ -60,5 +80,6 @@ and this project adheres to
#10, #11)
- GitHub Action workflows `check-standard` and `test-coverage` implemented (#5)

[unreleased]:
[upcoming]:
[0.0.2]:
[0.0.1]:
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: PoolPoweR
Type: Package
Title: Power and Sample Size Calculations for Surveys Using Pool Testing
Version: 0.0.1
Version: 0.1.0
Authors@R: c(
person(given = "Angus", family = "McLure", role = c("aut", "cre"),
email = "[email protected]",
Expand Down
13 changes: 7 additions & 6 deletions R/fisher_information.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fi_pool_cluster <- function(pool_size,
form = "beta",
real_scale = FALSE) {

check_input("form", form)
check_input("real_scale", real_scale)

s <- pool_size
Expand All @@ -119,9 +120,11 @@ fi_pool_cluster <- function(pool_size,
rho <- correlation
varphi <- sensitivity
psi <- specificity

if (length(s) != length(N) || !all((N %% 1) == 0) || !all(c(N, s) > 0)) {
stop("s and N must be vectors of positive numbers of common length. s can be non-integer, but N must be integer")

if (!is.numeric(c(s,N)) || length(s) != length(N) || !all((N %% 1) == 0) || !all(c(N, s) > 0)) {
# Not providing outputs for vectors because of nasty coercion hierarchies...
# and because this is "power-user" facing
stop("pool_size and pool_number must be vectors of positive numbers of common length. pool_size can be non-integer, but pool_number must be integer")
}

if (rho == 0) {
Expand Down Expand Up @@ -164,7 +167,7 @@ fi_pool_cluster <- function(pool_size,
# derivatives can be performed accordingly
if (form == "discrete") {
method <- "summation"
if (length(s) != 1) stop("unequal pool size not implemented for kind = 'discrete'")
if (length(s) != 1) stop("unequal pool size not implemented for form = 'discrete'")
# This models the prevalence at each site as a discrete distribution:
# values: 0, theta, 1
# weights: rho * (1-theta), (1-rho), rho * theta
Expand Down Expand Up @@ -534,8 +537,6 @@ fi_pool_cluster <- function(pool_size,
# FI on the {theta, rho} parameterisation
return(t(J) %*% FI %*% J)
}
} else {
stop("accepted forms of the site prevalence distribution (argument form) are logitnorm, cloglognorm, beta, and discrete.")
}
}

Expand Down
Loading

0 comments on commit 1373737

Please sign in to comment.