rhg_strata(sampling)
rhg_strata()所属R语言包:sampling
Response homogeneity groups for a stratified sampling
分层抽样的响应同质组
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Computes the response homogeneity groups and the response probability for each unit in these groups for a stratified sampling.
计算响应同质性团体和响应各单位在这些群体分层抽样的概率。
用法----------Usage----------
rhg_strata(X,selection)
参数----------Arguments----------
参数:X
sample data frame; it should contain the columns 'ID_unit','Stratum', and 'status'; 'ID_unit' denotes the unit identifier (a number); 'Stratum' denotes the unit stratum; 'status' is a 1/0 variable denoting the response/non-response of a unit in the sample.
样本数据框,它应该包含列“ID_unit的,阶层,和地位;ID_unit”表示设备识别码(数字),“阶层的代表单位阶层的”状态“1/0变量表示的响应/非响应的样品中的一个单元。
参数:selection
vector of variable names in X used to construct the groups.
X中的变量名的矢量用于构造的基团。
Details
详细信息----------Details----------
Into a response homogeneity group, the reponse probability is the same for all units. Data are missing at random within groups, conditionally on the selected sample.
到响应均匀性的基团,该响应的概率是相同的所有单元。数据组内随机缺失,有条件所选样本。
值----------Value----------
The initial sample data frame and also the following components:
最初的样本数据框和以下组件:
参数:rhgroup
the response homogeneity group for each unit conditionally on its stratum.
响应同质化集团各单位有条件的层数。
参数:prob_response
the response probability for each unit; for the units with status=0, this probability is 0.
每个单元;状态= 0的单位的响应概率,该概率是0。
参考文献----------References----------
参见----------See Also----------
rhg, calib
rhg,calib
实例----------Examples----------
############[###########]
## Example 1[#示例1]
############[###########]
# uses Example 2 from the 'strata' function help file[从“阶层”功能的帮助文件使用实例2]
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")
# draws a sample[绘制一个样本]
s1=strata(data,c("region","state"),size=c(10,5,10,4,6), method="systematic",
pik=data$income)
# extracts the observed data[提取所观察到的数据]
s1=getdata(data,s1)
# generates randomly the 'status' variable (1-sample respondent, 0-otherwise)[随机生成的“状态”变量(1个样品答辩,0,否则)]
status=runif(nrow(s1))
for(i in 1:length(status))
if(status[i]<0.3) status[i]=0 else status[i]=1
# adds the 'status' variable to the sample data frame s1[添加了“状态”变量的样本数据框S1]
s1=cbind.data.frame(s1,status)
# creates classes of income using the median of income[创建类的收入的中位数收入]
# suppose that the income is available for all units in sample[假设样品中各单位的收入可]
classincome=numeric(nrow(s1))
for(i in 1:length(classincome))
if(s1$income[i]<median(s1$income)) classincome[i]=1 else classincome[i]=2
# adds 'classincome' to s1[添加classincome“,到s1]
s1=cbind.data.frame(s1,classincome)
# computes the response homogeneity groups using the 'classincome' variable [计算响应同质化组变量“classincome”的]
rhg_strata(s1,selection=c("classincome"))
############[###########]
## Example 2[#示例2]
############[###########]
# the same data as in Example 1[在实施例1中相同的数据作为]
# but we also add the 'sex' column (1-female, 2-male)[但我们还添加了“性别”列(1女2男)]
# suppose that the sex is available for all units in sample[假设性是所有单位样品中]
sex=c(rep(1,12),rep(2,8),rep(1,10),rep(2,5))
s1=cbind.data.frame(s1,sex)
# computes the response homogeneity groups using the 'classincome' and 'sex' variables [计算响应均匀性,使用“classincome和性变量]
rhg_strata(s1,selection=c("classincome","sex"))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|