{"id":26631187,"url":"https://github.com/marberts/sps","last_synced_at":"2025-08-28T12:20:28.232Z","repository":{"id":56934123,"uuid":"326323827","full_name":"marberts/sps","owner":"marberts","description":"An R package for sequential Poisson sampling","archived":false,"fork":false,"pushed_at":"2025-07-10T02:28:41.000Z","size":11021,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-11T06:15:19.419Z","etag":null,"topics":["cran","official-statistics","r","r-package","rstats","sampling","statistics","survey-sampling"],"latest_commit_sha":null,"homepage":"https://marberts.github.io/sps/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marberts.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-03T04:03:23.000Z","updated_at":"2025-07-10T02:25:11.000Z","dependencies_parsed_at":"2023-10-16T04:33:16.371Z","dependency_job_id":"276efd9c-fbbf-4857-b3f8-c1c7707516ad","html_url":"https://github.com/marberts/sps","commit_stats":{"total_commits":148,"total_committers":2,"mean_commits":74.0,"dds":0.006756756756756799,"last_synced_commit":"1871fec4c0af02c2f6fa7bd87d5e5685bc37468f"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/marberts/sps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Fsps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Fsps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Fsps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Fsps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marberts","download_url":"https://codeload.github.com/marberts/sps/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Fsps/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266352520,"owners_count":23915766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran","official-statistics","r","r-package","rstats","sampling","statistics","survey-sampling"],"created_at":"2025-03-24T14:49:36.994Z","updated_at":"2025-08-28T12:20:28.221Z","avatar_url":"https://github.com/marberts.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file. --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  out.width = \"100%\"\n)\n```\n\n# Sequential Poisson sampling \u003ca href=\"https://marberts.github.io/sps/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\" alt=\"sps website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/sps)](https://cran.r-project.org/package=sps)\n[![sps status badge](https://marberts.r-universe.dev/badges/sps)](https://marberts.r-universe.dev)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/r-sps.svg)](https://anaconda.org/conda-forge/r-sps)\n[![R-CMD-check](https://github.com/marberts/sps/workflows/R-CMD-check/badge.svg)](https://github.com/marberts/sps/actions)\n[![codecov](https://codecov.io/gh/marberts/sps/graph/badge.svg?token=5CPGWUF267)]( https://app.codecov.io/gh/marberts/sps)\n[![DOI](https://zenodo.org/badge/326323827.svg)](https://zenodo.org/doi/10.5281/zenodo.10109857)\n[![Mentioned in Awesome Official Statistics ](https://awesome.re/mentioned-badge.svg)](https://github.com/SNStatComp/awesome-official-statistics-software)\n\u003c!-- badges: end --\u003e\n\nSequential 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).\n\n## Installation\n\nGet the stable release from CRAN.\n\n```{r, eval=FALSE}\ninstall.packages(\"sps\")\n```\n\nThe development version can be installed from R-Universe\n\n```{r, eval=FALSE}\ninstall.packages(\n  \"sps\",\n  repos = c(\"https://marberts.r-universe.dev\", \"https://cloud.r-project.org\")\n)\n```\n\nor directly from GitHub.\n\n```{r, eval=FALSE}\npak::pak(\"marberts/sps\")\n```\n\n## Usage\n\nGiven 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. \n\n```{r}\nlibrary(sps)\n\n# Generate some data on sizes for 12 businesses in a single\n# stratum as a simple example\nrevenue \u003c- c(1:10, 100, 150)\n\n# Draw a sample of 6 businesses\n(samp \u003c- sps(revenue, 6))\n\n# Design weights and sampling strata are stored with the sample\nweights(samp)\nlevels(samp)\n```\n\nAllocations 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.\n\n```{r}\n# Add some strata\nstratum \u003c- rep(c(\"a\", \"b\"), c(9, 3))\n\n# Make an allocation\n(allocation \u003c- prop_allocation(revenue, 6, stratum))\n\n# Draw a stratified sample\n(samp \u003c- sps(revenue, allocation, stratum))\n\nweights(samp)\nlevels(samp)\n```\n\nThe design weights for a sample can then be used to generate bootstrap replicate weights with the `sps_repweights()` function.\n\n```{r}\nsps_repweights(weights(samp), 5)\n```\n\nThe vignette gives more detail about how to use these functions to draw coordinated samples, top up a sample, and estimate variance.\n\n## Prior work\n\nThere 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).\n\n## Contributing\n\nAll 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.\n\n## References\n\nBeaumont, 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.\n\nOhlsson, E. (1998). Sequential Poisson Sampling. *Journal of Official Statistics*, 14(2): 149-162.\n\nRosén, B. (1997). On sampling with probability proportional to size. *Journal of Statistical Planning and Inference*, 62(2): 159-191.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarberts%2Fsps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarberts%2Fsps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarberts%2Fsps/lists"}