-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
59 lines (46 loc) · 1.2 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = FALSE
)
```
# sondage
<!-- badges: start -->
<!-- badges: end -->
The goal of sondage is to ...
## Installation
You can install the development version of sondage like so:
``` r
# install.packages("sondage")
pak::pkg_install("dickoa/sondage")
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(sondage)
set.seed(123)
p <- c(0.2, 0.25, 0.35, 0.4, 0.5, 0.5, 0.55, 0.65, 0.7, 0.9) # pik
N <- length(p)
marginal <- vector(mode = "numeric", length = N)
sequential <- vector(mode = "numeric", length = N)
nsim <- 1e5
for(i in 1:nsim){
s1 <- sample_int(N, prob = p,
replace = FALSE,
method = "sequential")
s2 <- sample_int(N, prob = p,
replace = FALSE,
method = "marginal")
sequential[s1] <- sequential[s1] + 1
marginal[s2] <- marginal[s2] + 1
}
cbind(pik = p,
sequential = sequential/nsim, marginal = marginal/nsim)
```