mardi 13 octobre 2020

mstage() for multistage sampling from `sampling` package in R

I'm using mstage() function from the sampling package to sample 100 students in 2 stages:

1st stage: stratify by 3 school types (stype) such that I have 10 of each school type

2nd stage: take one school district (dname) randomly from each of above strata

Everything works great. However, at the end, how can get random sample of 100 students from my final sample of students?

Is that going to come from xx[[1]] (first stage) or xx[[2]] (second stage)?

Or I also need to do another random sampling to get the final students sample after the 2 stages above?

library(survey)  # used for `apipop` data
library(sampling)

data(api) # loads `apipop` data

# 1st stage: stratify by 3 school types `stype` such that you have 10 of each school type 
# 2nd stage: take one school district `dname` randomly from each stratum

m <- mstage(apipop, stage=list("stratified","cluster"), varnames=list("stype","dname"), 
         size=list(c(10,10,10), c(1,1,1)),method=list("","srswor"), description=T)

xx <- getdata(apipop,m)

table(xx[[1]]$stype) # Great
table(xx[[2]]$dname) # Great BUT where is the final sample of students (that should be large)?



Aucun commentaire:

Enregistrer un commentaire