Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 32 additions & 42 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# --------------------------------------------
# CITATION file created with {cffr} R package
# ------------------------------------------------
# CITATION.cff file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
# ------------------------------------------------

cff-version: 1.2.0
message: 'To cite package "sps" in publications use:'
type: software
license: MIT
title: 'sps: Sequential Poisson Sampling'
version: 0.6.3
version: 0.6.4
doi: 10.5281/zenodo.10109857
identifiers:
- type: doi
Expand Down Expand Up @@ -36,7 +36,7 @@ preferred-citation:
year: '2025'
doi: 10.5281/zenodo.10109857
url: https://cran.r-project.org/package=sps
notes: R package version 0.6.3
notes: R package version 0.6.4
repository: https://CRAN.R-project.org/package=sps
repository-code: https://github.com/marberts/sps
url: https://marberts.github.io/sps/
Expand All @@ -61,75 +61,65 @@ references:
url: https://www.R-project.org/
authors:
- name: R Core Team
website: https://ror.org/02zz1nj61
institution:
name: R Foundation for Statistical Computing
website: https://ror.org/05qewa988
address: Vienna, Austria
year: '2025'
year: '2026'
doi: 10.32614/R.manuals
version: '>= 4.2'
- type: software
title: stats
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
website: https://ror.org/02zz1nj61
institution:
name: R Foundation for Statistical Computing
website: https://ror.org/05qewa988
address: Vienna, Austria
year: '2025'
year: '2026'
doi: 10.32614/R.manuals
- type: software
title: kit
abstract: 'kit: Data Manipulation Functions Implemented in C'
notes: Suggests
url: https://github.com/2005m/kit
url: https://fastverse.org/kit/
repository: https://CRAN.R-project.org/package=kit
authors:
- family-names: Jacob
given-names: Morgan
email: morgan.emailbox@gmail.com
year: '2025'
year: '2026'
doi: 10.32614/CRAN.package.kit
version: '>= 0.0.10'
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
title: litedown
abstract: 'litedown: A Lightweight Version of R Markdown'
notes: Suggests
url: https://yihui.org/knitr/
repository: https://CRAN.R-project.org/package=knitr
url: https://github.com/yihui/litedown
repository: https://CRAN.R-project.org/package=litedown
authors:
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
year: '2025'
doi: 10.32614/CRAN.package.knitr
year: '2026'
doi: 10.32614/CRAN.package.litedown
- type: software
title: quarto
abstract: 'quarto: R Interface to ''Quarto'' Markdown Publishing System'
title: tinytest
abstract: 'tinytest: Lightweight and Feature Complete Unit Testing Framework'
notes: Suggests
url: https://quarto-dev.github.io/quarto-r/
repository: https://CRAN.R-project.org/package=quarto
url: https://github.com/markvanderloo/tinytest
repository: https://CRAN.R-project.org/package=tinytest
authors:
- family-names: Allaire
given-names: JJ
email: jj@posit.co
orcid: https://orcid.org/0000-0003-0174-9868
- family-names: Dervieux
given-names: Christophe
email: cderv@posit.co
orcid: https://orcid.org/0000-0003-4474-2498
year: '2025'
doi: 10.32614/CRAN.package.quarto
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
url: https://testthat.r-lib.org
repository: https://CRAN.R-project.org/package=testthat
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2025'
doi: 10.32614/CRAN.package.testthat
version: '>= 3.0.0'
- family-names: Loo
given-names: Mark
name-particle: van der
email: mark.vanderloo@gmail.com
orcid: https://orcid.org/0000-0002-9807-4686
year: '2026'
doi: 10.32614/CRAN.package.tinytest

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sps
Title: Sequential Poisson Sampling
Version: 0.6.3.9004
Version: 0.6.4
Authors@R: c(
person("Steve", "Martin",
role = c("aut", "cre", "cph"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## sps (development version)
## sps 0.6.4

- Small improvements to the documentation.

Expand Down
6 changes: 3 additions & 3 deletions R/prop_allocation.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' Note that a divisor function with \eqn{d(0) = 0} (i.e., Huntington-Hill,
#' Adams, Dean) should have an initial allocation of at least 1 for all strata.
#' In all cases, ties are broken according to the sum of `x` if
#' `ties = 'largest'`; otherwise, if `ties = 'first'`, then ties are broken
#' `ties = "largest"`; otherwise, if `ties = "first"`, then ties are broken
#' according to the levels of `strata`.
#'
#' In cases where the number of units with non-zero size in a stratum is
Expand Down Expand Up @@ -50,9 +50,9 @@
#' @param divisor `[function]` A function for the divisor (highest-averages)
#' apportionment method. The default uses the Jefferson/D'Hondt method. See
#' details for other possible functions.
#' @param ties `[character(1)]` Either 'largest' to break ties in favor of the
#' @param ties `[character(1)]` Either `"largest"` to break ties in favor of the
#' stratum with the
#' largest size (the default), or 'first' to break ties in favor of the
#' largest size (the default), or `"first"` to break ties in favor of the
#' ordering of `strata`.
#' @param name `[character(1)]` Name of the divisor function. See details.
#'
Expand Down
18 changes: 10 additions & 8 deletions R/sps.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Order sampling (internal)
#' @noRd
order_sampling_ <- function(f) {
.order_sampling <- function(f) {
f <- match.fun(f)

function(p, n, u) {
Expand All @@ -19,7 +19,7 @@ order_sampling_ <- function(f) {

#' Ordinary Poisson sampling (internal)
#' @noRd
ps_ <- function(p, n, u) {
.ps <- function(p, n, u) {
which(u < p)
}

Expand Down Expand Up @@ -152,13 +152,13 @@ stratify <- function(f) {
#' population, distributed uniform between 0 and 1. The default does not use
#' permanent random numbers, instead generating a random vector when the
#' function is called.
#' @param alpha `[0 <= numeric < 1]` A numeric vector with values between 0 and
#' @param alpha `[0 <= numeric <= 1]` A numeric vector with values between 0 and
#' 1 for each stratum,
#' ordered according to the levels of `strata`. Units with inclusion
#' probabilities greater than or equal to 1 - `alpha` are set to 1 for
#' probabilities greater than or equal to `1 - alpha` are set to 1 for
#' each stratum. A single value is recycled for all strata. The default is
#' slightly larger than 0.
#' @param cutoff `[numeric >= 0]` A positive numeric vector of cutoffs for each
#' @param cutoff `[numeric > 0]` A positive numeric vector of cutoffs for each
#' stratum, ordered
#' according to the levels of `strata`. Units with `x >= cutoff` get
#' an inclusion probability of 1 for each stratum. A single value is recycled
Expand Down Expand Up @@ -192,6 +192,8 @@ stratify <- function(f) {
#'
#' [sps_repweights()] for generating bootstrap replicate weights.
#'
#' [sps_iterator()] for a drawing a sample one unit at a time.
#'
#' The `UPpoisson()` and `UPopips()` functions in the \pkg{sampling}
#' package for ordinary and sequential Poisson sampling, respectively. Note
#' that the algorithm for order sampling in the `UPopips()` function is
Expand Down Expand Up @@ -283,16 +285,16 @@ stratify <- function(f) {
#' order_sampling2(0)(x, 6, prn = u) # successive
#' order_sampling2(-1)(x, 6, prn = u) # Pareto
#' @export
sps <- stratify(order_sampling_(identity))
sps <- stratify(.order_sampling(identity))

#' Ordinary Poisson sampling
#' @rdname sps
#' @export
ps <- stratify(ps_)
ps <- stratify(.ps)

#' Factory to make order sampling schemes
#' @rdname sps
#' @export
order_sampling <- function(dist) {
stratify(order_sampling_(dist))
stratify(.order_sampling(dist))
}
18 changes: 7 additions & 11 deletions R/sps_iterator.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
#' @inheritParams sps
#' @param n `[integer(1) >= 0]` A positive integer giving the initial sample
#' size for the iterator. The default is 0.
#' @param alpha `[0 <= numeric(1) < 1]` A number between 0 and 1. Units with
#' inclusion probabilities greater than or equal to 1 - `alpha` are set to 1.
#' @param alpha `[0 <= numeric(1) <= 1]` A number between 0 and 1. Units with
#' inclusion probabilities greater than or equal to `1 - alpha` are set to 1.
#' The default is slightly larger than 0.
#' @param cutoff `[numeric(1) >= 0]` A numeric cutoff. Units with `x >= cutoff`
#' @param cutoff `[numeric(1) > 0]` A numeric cutoff. Units with `x >= cutoff`
#' get an inclusion probability of 1. The default does not apply a cutoff.
#'
#' @returns
#' A function that returns the next unit in the sample. It takes a single
#' argument giving the sentinel value to indicate that there are no units
#' left to sample (default `NULL`).
#'
#' @seealso
#' [sps()] for drawing a sequential Poisson sample.
#'
#' @examples
#' prn <- runif(5)
#' s <- sps_iterator(1:5, prn = prn)
Expand All @@ -32,14 +35,7 @@ sps_iterator <- function(x, n = 0L, prn = NULL, alpha = 0.001, cutoff = Inf) {
if (any(x <= 0)) {
stop("sizes must be strictly greater than 0")
}
if (is.null(prn)) {
prn <- stats::runif(length(x))
} else {
prn <- as.numeric(prn)
}
if (length(x) != length(prn)) {
stop("`x` and `prn` must be the same length")
}
prn <- random_deviates(prn, x)

s <- order(prn / x)
pop <- seq_along(s)
Expand Down
6 changes: 2 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
## Test environments

- local Ubuntu 24.04 installation, R 4.5.2
- local Ubuntu 24.04 installation, R 4.6.1
- win-builder (devel, release, oldrelease)
- github actions: Ubuntu (devel, release, oldrelease), Mac (release),
Windows (release)

## R CMD check results

There were no ERRORs or WARNINGs.

win-builder (oldrelease) gave two spurious NOTEs.
There were no ERRORs or WARNINGs or NOTEs.

## Downstream dependencies

Expand Down
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bibentry(
title = "{sps}: Sequential Poisson Sampling",
author = person("Steve", "Martin", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0003-2544-9480")),
year = "2025",
year = "2026",
doi = "10.5281/zenodo.10109857",
url = "https://cran.r-project.org/package=sps",
note = sprintf("R package version %s", meta$Version)
Expand Down
6 changes: 3 additions & 3 deletions man/expected_coverage.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/inclusion_prob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/prop_allocation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/sps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading