a****y 发帖数: 91 | 1 I am trying to understand the sampling from the following description. Does
anyone know how they get the sample stratum sizes: 10,5,10,4,6. Thanks a lot!
Generates artificial data (a 235X3 matrix with 3 columns: state, region,
income).
# The variable "state" has 2 categories (nc and sc).
# The variable "region" has 3 categories (1, 2 and 3).
# The sampling frame is stratified by region within state.
data=rbind(matrix(rep("nc",165),165,1,byrow=TRUE),matrix(rep("sc",70),70,1,
byrow=TRUE))
data=cbind.data.frame(data,c(rep(1,100), rep(2,50), rep(3,15), rep(1,30),rep
(2,40)),1000*runif(235))
names(data)=c("state","region","income")
# Computes the population stratum sizes
table(data$region,data$state)
# do not run
# nc sc
# 1 100 30
# 2 50 40
# 3 15 0
# there are 5 cells with non-zero values; one draws 5 samples (1 sample in
each stratum)
# the sample stratum sizes are 10,5,10,4,6, respectively | A*****a 发帖数: 1091 | 2 看了下这个完整的例子,他只是随意指定了size,来举例怎么使用strata这个命令罢了吧
Does
lot!
rep
【在 a****y 的大作中提到】 : I am trying to understand the sampling from the following description. Does : anyone know how they get the sample stratum sizes: 10,5,10,4,6. Thanks a lot! : Generates artificial data (a 235X3 matrix with 3 columns: state, region, : income). : # The variable "state" has 2 categories (nc and sc). : # The variable "region" has 3 categories (1, 2 and 3). : # The sampling frame is stratified by region within state. : data=rbind(matrix(rep("nc",165),165,1,byrow=TRUE),matrix(rep("sc",70),70,1, : byrow=TRUE)) : data=cbind.data.frame(data,c(rep(1,100), rep(2,50), rep(3,15), rep(1,30),rep
|
|