sps

An R package for sequential Poisson sampling

https://github.com/marberts/sps

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (18.1%) to scientific vocabulary

Keywords

cran official-statistics r r-package rstats sampling statistics survey-sampling
Last synced: 6 months ago · JSON representation ·

Repository

An R package for sequential Poisson sampling

Basic Info
Statistics
  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 7
Topics
cran official-statistics r r-package rstats sampling statistics survey-sampling
Created about 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Citation

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  out.width = "100%"
)
```

# Sequential Poisson sampling sps website


[![CRAN status](https://www.r-pkg.org/badges/version/sps)](https://cran.r-project.org/package=sps)
[![sps status badge](https://marberts.r-universe.dev/badges/sps)](https://marberts.r-universe.dev)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/r-sps.svg)](https://anaconda.org/conda-forge/r-sps)
[![R-CMD-check](https://github.com/marberts/sps/workflows/R-CMD-check/badge.svg)](https://github.com/marberts/sps/actions)
[![codecov](https://codecov.io/gh/marberts/sps/graph/badge.svg?token=5CPGWUF267)]( https://app.codecov.io/gh/marberts/sps)
[![DOI](https://zenodo.org/badge/326323827.svg)](https://zenodo.org/doi/10.5281/zenodo.10109857)
[![Mentioned in Awesome Official Statistics ](https://awesome.re/mentioned-badge.svg)](https://github.com/SNStatComp/awesome-official-statistics-software)


Sequential Poisson sampling is a variation of Poisson sampling for drawing probability-proportional-to-size samples with a given number of units, and is commonly used for price-index surveys. This package gives functions to draw stratified sequential Poisson samples according to the method by Ohlsson (1998), as well as other order sample designs by Rosén (1997), and generate approximate bootstrap replicate weights according to the generalized bootstrap method by Beaumont and Patak (2012).

## Installation

Get the stable release from CRAN.

```{r, eval=FALSE}
install.packages("sps")
```

The development version can be installed from R-Universe

```{r, eval=FALSE}
install.packages(
  "sps",
  repos = c("https://marberts.r-universe.dev", "https://cloud.r-project.org")
)
```

or directly from GitHub.

```{r, eval=FALSE}
pak::pak("marberts/sps")
```

## Usage

Given a vector of sizes for units in a population (e.g., revenue for sampling businesses) and a desired sample size, a stratified sequential Poisson sample can be drawn with the `sps()` function. 

```{r}
library(sps)

# Generate some data on sizes for 12 businesses in a single
# stratum as a simple example
revenue <- c(1:10, 100, 150)

# Draw a sample of 6 businesses
(samp <- sps(revenue, 6))

# Design weights and sampling strata are stored with the sample
weights(samp)
levels(samp)
```

Allocations are often proportional to size when drawing such samples, and the `prop_allocation()` function provides a variety of methods for generating proportional-to-size allocations.

```{r}
# Add some strata
stratum <- rep(c("a", "b"), c(9, 3))

# Make an allocation
(allocation <- prop_allocation(revenue, 6, stratum))

# Draw a stratified sample
(samp <- sps(revenue, allocation, stratum))

weights(samp)
levels(samp)
```

The design weights for a sample can then be used to generate bootstrap replicate weights with the `sps_repweights()` function.

```{r}
sps_repweights(weights(samp), 5)
```

The vignette gives more detail about how to use these functions to draw coordinated samples, top up a sample, and estimate variance.

## Prior work

There are many packages on CRAN for drawing samples proportional to size, but these generally do not include the sequential Poisson method. The **sampling** package contains a function for drawing sequential Poisson samples, but it does not allow for stratification, take-all units, or the use of permanent random numbers. By contrast, the **prnsamplr** package allows for the use of stratification and permanent random numbers with Pareto order sampling, but does not feature other order-sampling methods (like sequential Poisson).

## Contributing

All contributions are welcome. Please start by opening an issue on GitHub to report any bugs or suggest improvements and new features. See the contribution guidelines for this project for more information.

## References

Beaumont, J.-F. and Patak, Z. (2012). On the Generalized Bootstrap for Sample Surveys with Special Attention to Poisson Sampling. *International Statistical Review*, 80(1): 127-148.

Ohlsson, E. (1998). Sequential Poisson Sampling. *Journal of Official Statistics*, 14(2): 149-162.

Rosén, B. (1997). On sampling with probability proportional to size. *Journal of Statistical Planning and Inference*, 62(2): 159-191.

Owner

  • Name: Steve Martin
  • Login: marberts
  • Kind: user
  • Location: Ottawa, Canada
  • Company: Government of Canada

I build tools to measure inflation :chart_with_upwards_trend:

Citation (CITATION.cff)

# --------------------------------------------
# CITATION 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.2
doi: 10.5281/zenodo.10109857
identifiers:
- type: doi
  value: 10.32614/CRAN.package.sps
abstract: Sequential Poisson sampling is a variation of Poisson sampling for drawing
  probability-proportional-to-size samples with a given number of units, and is commonly
  used for price-index surveys. This package gives functions to draw stratified sequential
  Poisson samples according to the method by Ohlsson (1998, ISSN:0282-423X), as well
  as other order sample designs by Rosén (1997, <https://doi.org/10.1016/S0378-3758(96)00186-3>),
  and generate appropriate bootstrap replicate weights according to the generalized
  bootstrap method by Beaumont and Patak (2012, <https://doi.org/10.1111/j.1751-5823.2011.00166.x>).
authors:
- family-names: Martin
  given-names: Steve
  email: marberts@protonmail.com
  orcid: https://orcid.org/0000-0003-2544-9480
preferred-citation:
  type: manual
  title: 'sps: Sequential Poisson Sampling'
  authors:
  - family-names: Martin
    given-names: Steve
    orcid: https://orcid.org/0000-0003-2544-9480
    email: marberts@protonmail.com
  year: '2025'
  doi: 10.5281/zenodo.10109857
  url: https://cran.r-project.org/package=sps
  notes: R package version 0.6.2
repository: https://CRAN.R-project.org/package=sps
repository-code: https://github.com/marberts/sps
url: https://marberts.github.io/sps/
contact:
- family-names: Martin
  given-names: Steve
  email: marberts@protonmail.com
  orcid: https://orcid.org/0000-0003-2544-9480
keywords:
- cran
- official-statistics
- r
- r-package
- rstats
- sampling
- statistics
- survey-sampling
references:
- type: software
  title: 'R: A Language and Environment for Statistical Computing'
  notes: Depends
  url: https://www.R-project.org/
  authors:
  - name: R Core Team
  institution:
    name: R Foundation for Statistical Computing
    address: Vienna, Austria
  year: '2025'
  version: '>= 4.2'
- type: software
  title: stats
  abstract: 'R: A Language and Environment for Statistical Computing'
  notes: Imports
  authors:
  - name: R Core Team
  institution:
    name: R Foundation for Statistical Computing
    address: Vienna, Austria
  year: '2025'
- type: software
  title: kit
  abstract: 'kit: Data Manipulation Functions Implemented in C'
  notes: Suggests
  url: https://github.com/2005m/kit
  repository: https://CRAN.R-project.org/package=kit
  authors:
  - family-names: Jacob
    given-names: Morgan
    email: morgan.emailbox@gmail.com
  year: '2025'
  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'
  notes: Suggests
  url: https://yihui.org/knitr/
  repository: https://CRAN.R-project.org/package=knitr
  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
- type: software
  title: quarto
  abstract: 'quarto: R Interface to ''Quarto'' Markdown Publishing System'
  notes: Suggests
  url: https://quarto-dev.github.io/quarto-r/
  repository: https://CRAN.R-project.org/package=quarto
  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'

GitHub Events

Total
  • Create event: 6
  • Release event: 3
  • Issues event: 8
  • Watch event: 2
  • Issue comment event: 3
  • Push event: 57
  • Pull request event: 6
Last Year
  • Create event: 6
  • Release event: 3
  • Issues event: 8
  • Watch event: 2
  • Issue comment event: 3
  • Push event: 57
  • Pull request event: 6

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 185
  • Total Committers: 2
  • Avg Commits per committer: 92.5
  • Development Distribution Score (DDS): 0.005
Past Year
  • Commits: 19
  • Committers: 1
  • Avg Commits per committer: 19.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Steve Martin s****1@g****m 184
Steve Martin 1****m 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 4
  • Total pull requests: 6
  • Average time to close issues: about 3 hours
  • Average time to close pull requests: about 1 hour
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.67
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 5
  • Average time to close issues: about 3 hours
  • Average time to close pull requests: 30 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.8
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • marberts (4)
Pull Request Authors
  • marberts (5)
  • bezoingler (1)
Top Labels
Issue Labels
enhancement (1) bug (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 332 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 14
  • Total maintainers: 1
cran.r-project.org: sps

Sequential Poisson Sampling

  • Versions: 14
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 332 Last month
Rankings
Dependent packages count: 17.6%
Forks count: 21.3%
Average: 23.8%
Stargazers count: 23.8%
Dependent repos count: 24.4%
Downloads: 31.7%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5 depends
  • stats * imports
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite