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
8 changes: 4 additions & 4 deletions 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.9001
Version: 0.6.3.9003
Authors@R: c(
person("Steve", "Martin",
role = c("aut", "cre", "cph"),
Expand All @@ -21,13 +21,13 @@ Depends: R (>= 4.2)
Imports: stats
Suggests:
kit (>= 0.0.10),
knitr,
quarto,
litedown,
rbibutils,
tinytest
License: MIT + file LICENSE
Encoding: UTF-8
URL: https://marberts.github.io/sps/, https://github.com/marberts/sps
BugReports: https://github.com/marberts/sps/issues
VignetteBuilder: quarto
VignetteBuilder: litedown
Roxygen: list(markdown = TRUE)
Config/roxygen2/version: 8.0.0
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- Small improvements to the documentation.

- Now using `{tinytest}`.
- Now using `{tinytest}` and `{litedown}`.

## sps 0.6.3

Expand Down
2 changes: 2 additions & 0 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
citHeader("To cite sps in publications use:")

bibentry(
bibtype = "Manual",
title = "{sps}: Sequential Poisson Sampling",
Expand Down
27 changes: 27 additions & 0 deletions vignettes/ref.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@article{ohlsson1998,
title = {Sequential {P}oisson sampling},
author = {Ohlsson, E.},
year = {1998},
journal = {Journal of Official Statistics},
number = {2},
volume = {14},
pages = {149--162}
}

@book{tille2020,
title = {Sampling and Estimation from Finite Populations},
author = {Tillé, Y},
year = {2020},
publisher = {Wiley},
doi = {10.1002/9781119071259}
}

@article{tille2023,
title = {Remarks on some misconceptions about unequal probability sampling without replacement},
author = {Tillé, Y},
year = {2023},
journal = {Computer Science Review},
volume = {47},
pages = {100533},
doi = {10.1016/j.cosrev.2022.100533}
}
12 changes: 4 additions & 8 deletions vignettes/sps.qmd → vignettes/sps.Rmd
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
---
title: "Drawing a Sequential Poisson Sample"
bibliography: ref.bib
vignette: >
%\VignetteIndexEntry{Drawing a Sequential Poisson Sample}
%\VignetteEngine{quarto::html}
%\VignetteEngine{litedown::vignette}
%\VignetteEncoding{UTF-8}
knitr:
opts_chunk:
collapse: true
comment: '#>'
---

Sequential Poisson sampling is a variation of Poisson sampling for drawing probability-proportional-to-size samples with a given number of units. It's a fast, simple, and flexible method for sampling units proportional to their size, and is often used for drawing a sample of businesses. The purpose of this vignette is to give an example of how the functions in this package can be used to easily draw a sample using the sequential Poisson method. More details can be found on the help pages for the functions used in this vignette.
Sequential Poisson sampling is a variation of Poisson sampling for drawing probability-proportional-to-size samples with a given number of units. It's a fast, simple, and flexible method for sampling units proportional to their size, and is often used for drawing a sample of businesses. The purpose of this vignette is to give an example of how the functions in this package can be used to easily draw a sample using the sequential Poisson method. More details, including references to the literature, can be found on the help pages for the functions used in this vignette. @tille2020 (Chapter 5) gives a textbook treatment of this method and how it compares with other probability-proportional-to-size sampling methods.

## Drawing a sample of businesses

Expand Down Expand Up @@ -211,7 +208,7 @@ summary(sampling_distribution / sum(sales) - 1)
```

More generally, the distribution of inclusion probabilities
is usually close to what is expected if sequential Poisson sampling was exactly proportional to size.^[See Tillé, Y. (2023). Remarks on some misconceptions about unequal probability sampling without replacement. *Computer Science Review*, 47, 100533.]
is usually close to what is expected if sequential Poisson sampling was exactly proportional to size [@tille2023].

```{r tille, fig.width=8, fig.height=5.33}
#| fig.alt: >
Expand Down Expand Up @@ -241,4 +238,3 @@ plot(
lines(seq(-4, 4, 0.1), dnorm(seq(-4, 4, 0.1)), lty = "dashed")
legend("topright", c("empirical", "theoretical"), lty = c("solid", "dashed"))
```

29 changes: 20 additions & 9 deletions vignettes/take-all.qmd → vignettes/take-all.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ title: "Take-all units"
format:
html:
html-math-method: mathjax
bibliography: ref.bib
vignette: >
%\VignetteIndexEntry{Take-all units}
%\VignetteEngine{quarto::html}
%\VignetteEngine{litedown::vignette}
%\VignetteEncoding{UTF-8}
knitr:
opts_chunk:
collapse: true
comment: '#>'
---

When drawing a sample of size $n$ from a population of size $N$,
Expand All @@ -27,16 +24,20 @@ probability greater than 1, especially when $n$ is large. The usual procedure to
deal with these units is to
put them in a special take-all stratum so that they are always included in the
sample, essentially fixing their inclusion probabilities at 1, with the
remaining units (the take-some units) drawn at random. The
remaining units (the take-some units) drawn at random; see, e.g., @ohlsson1998
or @tille2020 (Chapter 5). The
usual algorithm used by, say, `sampling::inclusionprobabilities()`
repeatedly moves units into the take-all stratum
and recalculates the inclusion probabilities for the remaining units
until all inclusion probabilities are less than 1.^[To see why this needs
until all inclusion probabilities are less than 1.[^1]

[^1]: To see why this needs
to be done repeatedly, consider a population with three units with sizes 1, 2, and 3
and find which units have an inclusion probability greater than 1 when the sample
size is 3.]
size is 3.

Sequential poisson sampling is a bit more complicated because it can be useful
Sequential poisson sampling is a bit more complicated because, as noted by
@ohlsson1998, it can be useful
to place units with an inclusion probability greater than $1 - \alpha$, for some
small $\alpha$, into the take-all stratum. Unless $\alpha = 0$, the usual algorithm
for finding take-all units can put units into the take-all stratum that have
Expand Down Expand Up @@ -172,3 +173,13 @@ legend(1, 2.5, c("take-some", "take-all"), pch = c(20, 19))
legend(1, 2, c("n = 8", "n = 9"), pch = 20, col = c("black", "red"))
symbols(4.5, 0.85, circles = 1, inches = FALSE, add = TRUE, lty = 2)
```

This can be calculated for each unit in the population.

```{r}
sps::becomes_ta(x, alpha = alpha)
```

Knowing when a unit enters the take-all stratum also makes it possible to draw
units one at a time with the sequential Poisson method, as with the `sps_iterator()`
function.
Loading