找回密码
 注册
查看: 4430|回复: 0

R语言 sampling包 strata()函数中文帮助文档(中英文对照)

  [复制链接]
发表于 2012-9-29 21:50:53 | 显示全部楼层 |阅读模式
strata(sampling)
strata()所属R语言包:sampling

                                        Stratified sampling
                                         分层抽样

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Stratified sampling with equal/unequal probabilities.
分层抽样与平等/不平等的概率。


用法----------Usage----------





参数----------Arguments----------

参数:data
data frame or data matrix; its number of rows is N, the population size.
数据框或数据矩阵,其行数为N,人口规模。


参数:stratanames
vector of stratification variables.
矢量分层变量。


参数:size
vector of stratum sample sizes (in the order in which the strata are given in the input data set).
矢量层的样本大小(在输入数据集的顺序,地层)。


参数:method
method to select units; the following methods are implemented: simple random  sampling without replacement (srswor), simple random sampling with replacement (srswr),  Poisson sampling (poisson), systematic sampling (systematic); if "method" is missing,  the default method is "srswor".
方法选择单位;下面的方法来实现:(srswor),无需更换的更换(srswr),(泊松)泊松抽样,系统抽样(系统)如果缺少“办法”,简单随机抽样简单随机抽样默认法“srswor”。


参数:pik
vector of inclusion probabilities or auxiliary information used to compute them;  this argument is only used for unequal probability sampling (Poisson and systematic). If an auxiliary information is provided, the function uses the inclusionprobabilities function for computing these probabilities. If the method is "srswr" and the sample size is larger than the population size, this vector is normalized to one.
矢量包含概率或用于计算的辅助信息;这种说法仅用于不等概率抽样(泊松和系统的)。如果提供辅助信息,该函数使用inclusionprobabilities功能,计算这些概率。如果该方法是“srswr”样本规模较大的人口规模相比,该矢量归一。


参数:description
a message is printed if its value is TRUE; the message gives the number  of selected units and the number of the units in the population.  By default, the value is FALSE.
打印一条消息,如果它的值是TRUE;讯息给选定的单元的数目和人口中的单位数。默认情况下,该值是FALSE。


Details

详细信息----------Details----------

The data should be sorted in ascending order by the columns given in the stratanames argument before applying the function. Use, for example, data[order(data$state,data$region),].
的数据应以递增顺序排序的列在提出申请前的功能在stratanames参数。使用,例如,数据的顺序(数据状态,数据区域)]。


值----------Value----------

The function produces an object, which contains the following information:
该函数产生一个对象,它包含以下信息:


参数:ID_unit
the identifier of the selected units.
所选单元的标识符。


参数:Stratum
the unit stratum.
单位阶层。


参数:Prob
the final unit inclusion probability.
最后一个单元包含概率。


参见----------See Also----------

getdata, mstage
getdata,mstage


实例----------Examples----------


############[###########]
## Example 1[#示例1]
############[###########]
# Example from An and Watts (New SAS procedures for Analysis of Sample Survey Data)[和瓦(抽样调查数据分析的SAS程序实例)]
# generates artificial data (a 235X3 matrix with 3 columns: state, region, income).[生成人工数据(3一个235X3矩阵,列:国家,区域,收入)。]
# the variable "state" has 2 categories ('nc' and 'sc'). [的变量“状态”有2个类别(“NC”和“SC”)。]
# the variable "region" has 3 categories (1, 2 and 3).[可变的“区域”具有3个类别,(1,2和3)。]
# the sampling frame is stratified by region within state.[抽样框是分层的区域内状态。]
# the income variable is randomly generated[收入变量是随机生成的]
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)
# not run[不运行]
#     nc  sc[NC SC]
#  1 100  30[1 100 30]
#  2  50  40[2 50 40]
#  3  15   0[3月15日0]
# there are 5 cells with non-zero values[有5个单元与非零值]
# one draws 5 samples (1 sample in each stratum)[一个绘制5个样品(1个样本在各阶层)]
# the sample stratum sizes are 10,5,10,4,6, respectively[样品阶层的大小是10,5,10,4,6,分别]
# the method is 'srswor' (equal probability, without replacement)[该方法是srswor“(概率相等,无需更换)]
s=strata(data,c("region","state"),size=c(10,5,10,4,6), method="srswor")
# extracts the observed data[提取所观察到的数据]
getdata(data,s)
# see the result using a contigency table[看到的结果使用contigency表]
table(s$region,s$state)
############[###########]
## Example 2[#示例2]
############[###########]
# The same data as in Example 1[在实施例1中相同的数据作为]
# the method is 'systematic' (unequal probability, without replacement)[该方法是系统(不等概率,无需更换)]
# the selection probabilities are computed using the variable 'income'[选择概率计算使用的变量收入]
s=strata(data,c("region","state"),size=c(10,5,10,4,6), method="systematic",pik=data$income)
# extracts the observed data[提取所观察到的数据]
getdata(data,s)
# see the result using a contigency table[看到的结果使用contigency表]
table(s$region,s$state)
############[###########]
## Example 3[#示例3]
############[###########]
# Uses the 'swissmunicipalities' data as population for drawing a sample of units[使用“swissmunicipalities”人口的数据抽取一个样本单位]
data(swissmunicipalities)
# the variable 'REG' has 7 categories in the population[变量的REG“在人群中,有7个类别,]
# it is used as stratification variable[它是用来作为分层变量]
# Computes the population stratum sizes[计算人口阶层大小]
table(swissmunicipalities$REG)
# do not run[不运行]
#  1   2   3   4   5   6   7 [1 2 3 4 5 6 7]
# 589 913 321 171 471 186 245 [589 913 321 171 471 186 245]
# the sample stratum sizes are given by size=c(30,20,45,15,20,11,44)[样品层尺寸大小= C(30,20,45,15,20,11,44)]
# 30 units are drawn from the first stratum, 20 in the second one, etc.[来自30个单位的第一层,20在第二个,等等。]
# the method is simple random sampling without replacement [方法很简单随机抽样,无需更换]
# (equal probability, without replacement)[(概率相等,无需更换)]
st=strata(swissmunicipalities,stratanames=c("REG"),size=c(30,20,45,15,20,11,44),
method="srswor")
# extracts the observed data[提取所观察到的数据]
# the order of the columns is different from the order in the initial database[的初始数据库中的列的顺序不同的顺序]
getdata(swissmunicipalities, st)
# see the result using a contingency table[使用列联表的结果]
table(st$REG)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-23 11:00 , Processed in 0.020230 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表