Description Usage Arguments Details Value Author(s) See Also Examples
A convenience wrapper for setting up multiple samples using setup
with control class SampleControl
.
1 2 3 |
x |
the |
design |
a character, logical or numeric vector specifying variables (columns) to be used for stratified sampling. |
grouping |
a character string, single integer or logical vector specifying a grouping variable (column) to be used for sampling whole groups rather than individual observations. |
collect |
logical; if a grouping variable is specified and this is
|
fun |
a function to be used for sampling (defaults to
|
size |
an optional non-negative integer giving the number of items (observations or groups) to sample. For stratified sampling, a vector of non-negative integers, each giving the number of items to sample from the corresponding stratum. |
prob |
an optional numeric vector giving the probability weights, or a character string or logical vector specifying a variable (column) that contains the probability weights. |
... |
additional arguments to be passed to |
k |
a single positive integer giving the number of samples to be set up. |
There are some restrictions on the argument names of the function
supplied to fun
. If it needs population data as input,
the corresponding argument should be called x
and should expect
a data.frame
. If the sampling method only needs the population size
as input, the argument should be called N
. Note that fun
is
not expected to have both x
and N
as arguments, and that the
latter is much faster for stratified sampling or group sampling.
Furthermore, if the function has arguments for sample size and probability
weights, they should be called size
and prob
, respectively.
Note that a function with prob
as its only argument is perfectly valid
(for probability proportional to size sampling). Further arguments of
fun
may be passed directly via the ... argument.
An object of class "SampleSetup"
.
Andreas Alfons
setup
, "SampleControl"
,
"SampleSetup"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | data(eusilcP)
## simple random sampling
srss <- simSample(eusilcP, size = 20, k = 4)
summary(srss)
draw(eusilcP[, c("id", "eqIncome")], srss, i = 1)
## group sampling
gss <- simSample(eusilcP, grouping = "hid", size = 10, k = 4)
summary(gss)
draw(eusilcP[, c("hid", "id", "eqIncome")], gss, i = 2)
## stratified simple random sampling
ssrss <- simSample(eusilcP, design = "region",
size = c(2, 5, 5, 3, 4, 5, 3, 5, 2), k = 4)
summary(ssrss)
draw(eusilcP[, c("id", "region", "eqIncome")], ssrss, i = 3)
## stratified group sampling
sgss <- simSample(eusilcP, design = "region",
grouping = "hid", size = c(2, 5, 5, 3, 4, 5, 3, 5, 2), k = 4)
summary(sgss)
draw(eusilcP[, c("hid", "id", "region", "eqIncome")], sgss, i = 4)
|
Loading required package: Rcpp
Loading required package: lattice
Loading required package: parallel
4 samples of size 20 are set up
id eqIncome .weight
44781 0583701 7408.812 2932.7
55225 0908501 13150.719 2932.7
8929 2150303 5087.309 2932.7
57587 0663501 30261.224 2932.7
29927 1247901 8529.250 2932.7
15133 0536901 14579.030 2932.7
46794 0048001 20208.983 2932.7
22979 0131804 18798.567 2932.7
43668 2149904 25803.290 2932.7
21427 2324203 3728.690 2932.7
50488 1630503 19317.838 2932.7
25392 0675102 12960.508 2932.7
36412 2111106 14549.529 2932.7
54592 0790701 18187.348 2932.7
2801 1081101 16107.480 2932.7
20580 0344302 16844.455 2932.7
6794 2313002 13717.056 2932.7
47580 1426601 15439.830 2932.7
51349 0129001 12873.930 2932.7
35105 1615404 19390.895 2932.7
4 samples are set up
The sample sizes are:
[1] 16 23 30 23
hid id eqIncome .weight
54860 6760 0676001 22715.12 2500
54861 6760 0676002 22715.12 2500
54862 6760 0676003 22715.12 2500
54863 6760 0676004 22715.12 2500
52701 12019 1201901 21516.05 2500
52702 12019 1201902 21516.05 2500
48378 16474 1647401 17766.26 2500
48379 16474 1647402 17766.26 2500
47313 16753 1675301 12234.74 2500
55863 17261 1726101 17578.60 2500
55864 17261 1726102 17578.60 2500
55865 17261 1726103 17578.60 2500
55866 17261 1726104 17578.60 2500
55867 17261 1726105 17578.60 2500
55868 17261 1726106 17578.60 2500
23348 17520 1752001 23458.96 2500
23349 17520 1752002 23458.96 2500
23350 17520 1752003 23458.96 2500
23351 17520 1752004 23458.96 2500
37907 18552 1855201 12242.75 2500
14127 19861 1986101 28873.94 2500
38101 20247 2024701 17827.90 2500
47792 21898 2189801 19432.71 2500
4 samples of size 34 are set up
id region eqIncome .weight
848 1377102 Burgenland 13792.933 970.500
124 1419801 Burgenland 10069.840 970.500
12051 1764402 Lower Austria 19825.510 2225.400
5889 2084302 Lower Austria 35641.487 2225.400
4581 1518202 Lower Austria 13777.713 2225.400
12817 1332204 Lower Austria 22271.959 2225.400
11817 2383003 Lower Austria 31400.319 2225.400
16231 1359401 Vienna 33437.247 2331.400
19560 2193402 Vienna 8987.905 2331.400
14495 0684501 Vienna 15943.850 2331.400
13942 1020901 Vienna 22582.580 2331.400
24253 1229303 Vienna 20973.676 2331.400
27607 1834102 Carinthia 23515.616 1370.333
26458 1438703 Carinthia 27484.585 1370.333
28113 1119104 Carinthia 15084.129 1370.333
32191 2027002 Styria 11937.517 2035.500
29192 0862301 Styria 20915.180 2035.500
36787 0120801 Styria 13743.909 2035.500
30767 0328902 Styria 19158.700 2035.500
38670 1158902 Upper Austria 10548.640 2062.000
43978 1256502 Upper Austria 16259.120 2062.000
45116 1796702 Upper Austria 20633.990 2062.000
41191 0929302 Upper Austria 17255.994 2062.000
38451 0272201 Upper Austria 33015.413 2062.000
51307 0553802 Salzburg 8530.734 1341.667
50679 1871905 Salzburg 22256.032 1341.667
48756 0782301 Salzburg 13910.353 1341.667
52154 0052302 Tyrol 8306.500 959.200
53284 0274502 Tyrol 35249.120 959.200
53408 1651303 Tyrol 44624.300 959.200
51972 1341302 Tyrol 9911.427 959.200
52100 1214602 Tyrol 7874.813 959.200
57660 0281502 Vorarlberg 33374.481 1272.500
56527 1114102 Vorarlberg 38700.500 1272.500
4 samples are set up
The sample sizes are:
[1] 79 76 79 67
hid id region eqIncome .weight
699 14709 1470901 Burgenland 38682.593 399.5000
700 14709 1470902 Burgenland 38682.593 399.5000
533 18149 1814901 Burgenland 11470.193 399.5000
534 18149 1814902 Burgenland 11470.193 399.5000
2312 2576 0257601 Lower Austria 8789.020 923.8000
11480 4356 0435601 Lower Austria 5962.886 923.8000
11481 4356 0435602 Lower Austria 5962.886 923.8000
11482 4356 0435603 Lower Austria 5962.886 923.8000
11483 4356 0435604 Lower Austria 5962.886 923.8000
11484 4356 0435605 Lower Austria 5962.886 923.8000
10791 8206 0820601 Lower Austria 16756.295 923.8000
10792 8206 0820602 Lower Austria 16756.295 923.8000
10793 8206 0820603 Lower Austria 16756.295 923.8000
10794 8206 0820604 Lower Austria 16756.295 923.8000
3052 10355 1035501 Lower Austria 8890.380 923.8000
8955 15306 1530601 Lower Austria 17140.824 923.8000
8956 15306 1530602 Lower Austria 17140.824 923.8000
8957 15306 1530603 Lower Austria 17140.824 923.8000
8958 15306 1530604 Lower Austria 17140.824 923.8000
13704 1100 0110001 Vienna 15783.840 1171.4000
16789 4723 0472301 Vienna 21222.780 1171.4000
16790 4723 0472302 Vienna 21222.780 1171.4000
16701 7343 0734301 Vienna 10985.847 1171.4000
16702 7343 0734302 Vienna 10985.847 1171.4000
15277 19097 1909701 Vienna 19555.910 1171.4000
19454 23740 2374001 Vienna 25573.844 1171.4000
19455 23740 2374002 Vienna 25573.844 1171.4000
19456 23740 2374003 Vienna 25573.844 1171.4000
25015 5541 0554101 Carinthia 9337.900 574.3333
25151 5546 0554601 Carinthia 18418.970 574.3333
27854 9312 0931201 Carinthia 19180.829 574.3333
27855 9312 0931202 Carinthia 19180.829 574.3333
27856 9312 0931203 Carinthia 19180.829 574.3333
27857 9312 0931204 Carinthia 19180.829 574.3333
30106 4316 0431601 Styria 17640.120 846.5000
30107 4316 0431602 Styria 17640.120 846.5000
31046 6281 0628101 Styria 8002.267 846.5000
31047 6281 0628102 Styria 8002.267 846.5000
29586 10153 1015301 Styria 10606.800 846.5000
28908 16619 1661901 Styria 16090.580 846.5000
41667 619 0061901 Upper Austria 26472.222 814.2000
41668 619 0061902 Upper Austria 26472.222 814.2000
41669 619 0061903 Upper Austria 26472.222 814.2000
37653 8995 0899501 Upper Austria 10231.330 814.2000
37602 14204 1420401 Upper Austria 8809.400 814.2000
39697 16921 1692101 Upper Austria 11493.213 814.2000
39698 16921 1692102 Upper Austria 11493.213 814.2000
37214 23989 2398901 Upper Austria 2935.070 814.2000
47560 8201 0820101 Salzburg 9897.610 557.0000
48502 16351 1635101 Salzburg 12465.747 557.0000
48503 16351 1635102 Salzburg 12465.747 557.0000
48542 22025 2202501 Salzburg 20132.767 557.0000
48543 22025 2202502 Salzburg 20132.767 557.0000
52727 1991 0199101 Tyrol 4940.987 377.8000
52728 1991 0199102 Tyrol 4940.987 377.8000
53574 3078 0307801 Tyrol 28626.755 377.8000
53575 3078 0307802 Tyrol 28626.755 377.8000
53576 3078 0307803 Tyrol 28626.755 377.8000
51522 10520 1052001 Tyrol 11166.180 377.8000
52687 11739 1173901 Tyrol 20082.700 377.8000
52688 11739 1173902 Tyrol 20082.700 377.8000
54952 16371 1637101 Tyrol 35377.960 377.8000
54953 16371 1637102 Tyrol 35377.960 377.8000
54954 16371 1637103 Tyrol 35377.960 377.8000
54955 16371 1637104 Tyrol 35377.960 377.8000
56238 8126 0812601 Vorarlberg 12080.200 492.5000
56365 9824 0982401 Vorarlberg 12132.820 492.5000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.