R strata()

1 개요[ | ]

R strata()
  • "Stratified Sampling"
method
srswor (기본값) simple random sampling without replacement → 비복원 단순랜덤샘플링
srswr simple random sampling with replacement → 복원 단순랜덤샘플링
poisson Poisson sampling → 포아송 샘플링
systematic systematic sampling → 체계적 샘플링

2 예시[ | ]

R
CPU
2.6s
MEM
113M
2.8s
Reload
Copy
summary(warpbreaks)
     breaks      wool   tension
 Min.   :10.00   A:27   L:18   
 1st Qu.:18.25   B:27   M:18   
 Median :26.00          H:18   
 Mean   :28.15                 
 3rd Qu.:34.00                 
 Max.   :70.00                 
Copy
table(warpbreaks$wool,warpbreaks$tension)
   
    L M H
  A 9 9 9
  B 9 9 9
Copy
library(sampling)
s <- strata(warpbreaks,c("wool","tension"),size=c(2,2,2,2,2,2),method="srswor")
s
A data.frame: 12 × 5
wooltensionID_unitProbStratum
<fct><fct><int><dbl><int>
5AL 50.22222221
8AL 80.22222221
12AM120.22222222
13AM130.22222222
20AH200.22222223
22AH220.22222223
32BL320.22222224
36BL360.22222224
40BM400.22222225
41BM410.22222225
49BH490.22222226
53BH530.22222226
Copy
getdata(warpbreaks, s)
A data.frame: 12 × 6
breakswooltensionID_unitProbStratum
<dbl><fct><fct><int><dbl><int>
570AL 50.22222221
826AL 80.22222221
1229AM120.22222222
1317AM130.22222222
2021AH200.22222223
2218AH220.22222223
3229BL320.22222224
3644BL360.22222224
4016BM400.22222225
4139BM410.22222225
4917BH490.22222226
5316BH530.22222226

3 같이 보기[ | ]

4 참고[ | ]