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

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

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

                                        Multistage sampling
                                         多阶段抽样

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

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

Implements multistage sampling with equal/unequal probabilities.
实现相等/不等概率多阶段抽样。


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





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

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


参数:stage
list of sampling type at each stage; the possible values are: "stratified", "cluster"  and "" (without stratification or clustering). For multistage element sampling, this argument is not necessary.
采样类型的列表,在每个阶段可能的值有:“分层”,“聚类”和“(不分层聚类)。对于多级元素取样,这种说法是没有必要的。


参数:varnames
list of stratification or clustering variables.
分层或聚类变量列表。


参数:size
list of sample sizes (in the order in which the samples appear in the multistage sampling).
样本大小的列表(在样品中的顺序出现在多级采样)。


参数: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 the method is not specified,  by default, the method is "srswor".
方法选择单位;以下方法来实现:(srswor)无需更换,更换(srswr)(泊松分布),泊松抽样,系统抽样(系统),如果该方法没有指定,默认情况下,简单随机抽样与简单随机抽样的方法,该方法是“srswor”。


参数:pik
list of selection probabilities or auxiliary information used to compute them;  this argument is only used for unequal probability sampling (Poisson, 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, the selection probabilities are 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, its value is FALSE.
打印一条消息,如果它的值是TRUE;讯息给选定的单元的数目和人口中的单位数。默认情况下,它的值是FALSE。


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

The function returns a list, which contains the stages (if m is this list, the stage i is m$'i' etc) and the following information:
该函数返回一个列表,其中包含的阶段(如果m是这个名单,在第一阶段是M $的“i”等)和以下信息:


参数:ID_unit
the identifier of selected units at each stage.
在每个阶段选定的单元的标识符。


参数:Prob_ number _stage
the inclusion probability at stage 'number'.
的包含概率阶段数。


参数:Prob
the final unit inclusion probability given in the last stage; it is the product of  the unit inclusion probabilities at each stage.
给出的最后一个单元包含概率在最后阶段,它是产品的单元在每个阶段包含概率。


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

cluster, strata, getdata
cluster,strata,getdata


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


############[###########]
## Example 1[#示例1]
############[###########]
# Two-stage cluster sampling[两阶段整群抽样]
# Uses the 'swissmunicipalities' data for drawing a sample of units[使用swissmunicipalities数据绘制一组单位样本]
data(swissmunicipalities)
# the variable 'REG' (region) has 7 categories;[变量的REG(区域)有7个类别;]
# it is used as clustering variable in the first-stage sample[在第一阶段的样品,它是用来作为聚类变量]
# the variable 'CT' (canton) has 26 categories; [变量CT(州)有26个类别;]
# it is used as clustering variable in the second-stage sample[在第二阶段的样品,它是用来作为聚类变量]
# 4 clusters (regions) are selected in the first-stage [4簇(区域)的第一阶段中选择]
# 1 canton is selected in the second-stage from each sampled cluster [1州是从每个采样的聚类中选择的第二阶段]
# the method is simple random sampling without replacement [方法很简单随机抽样,无需更换]
# (equal probability, without replacement)[(概率相等,无需更换)]
m=mstage(swissmunicipalities,stage=list("cluster","cluster"), varnames=list("REG","CT"),
size=list(4,c(1,1,1,1)), method="srswor")
# the first stage is m$'1' and the second stage is m$'2'[第一阶段是M $ 1,第二个阶段是M $ 2]
# extracts the observed data[提取所观察到的数据]
# the order of the columns is different from the order in the swsissmunicipalities database[列的顺序是不同的顺序在swsissmunicipalities数据库]
getdata(swissmunicipalities, m)
############[###########]
## Example 2[#示例2]
############[###########]
# Two-stage element sampling[两个阶段的元素取样]
# 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 variable "income" is generated using the U(0,1) distribution. [使用U(0,1)分布的变量“收入”的产生。]
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)),
100*runif(235))
names(data)=c("state","region","income")
# the method is simple random sampling with replacement[方法很简单随机抽样与更换]
# 25 units are drawn in the first-stage[在第一阶段的25个单位绘制]
# in the second-stage, 10 units are drawn from the already 25 selected units[在第二阶段中,10个单位从已有25个选定的单位绘制]
m=mstage(data,size=list(25,10),method="srswr")
# extracts the observed data[提取所观察到的数据]
getdata(data,m)
############[###########]
## Example 3[#示例3]
############[###########]
# One-stage stratified cluster sampling[一阶段分层整群抽样]
# The same data as in Example 2[在实施例2中相同的数据作为]
# the variable 'state' is used as stratification variable [“状态”变量作为分层变量]
# 165 units are in the first stratum and 70 in the second one[165个单位是在第一层和70中的第二个]
# the variable 'region' is used as clustering variable[作为聚类变量的变量“区域”]
# 1 cluster (region) is drawn in each stratum using the "srswor" method[1聚类(区域)中绘制各阶层使用“srswor”的方法]
m=mstage(data, stage=list("stratified","cluster"), varnames=list("state","region"),
size=list(c(165,70),c(1,1)),method="srswor")
# extracts the observed data[提取所观察到的数据]
getdata(data,m)
# verify the result using a contigency table[验证结果使用contigency表]
xx=getdata(data,m)
table(xx[[2]]$state,xx[[2]]$region)
############[###########]
## Example 4[#例4]
############[###########]
# Two-stage cluster sampling[两阶段整群抽样]
# The same data as in Example 1[在实施例1中相同的数据作为]
data(swissmunicipalities)
# in the first-stage, the clustering variable is 'REG' (region) with 7 categories[在第一阶段中,聚类化的变量是“REG(区域)与7类]
# each region is selected with the probability 1/7[每个区域被选择的概率是1/7]
# in the second-stage, the clustering variable is 'CT'(canton) with 26 categories[在第二阶段,聚类变量是CT(州),26个类别]
# in the region 1, there are 3 cantons and each canton is selected with the prob. 1/3[在区域1中,有3个州和每个州被选择的概率。三分之一]
# in the region 2, there are 5 cantons and each canton is selected with the prob. 1/5[在区域2中,有5个州,每个州被选择的概率。 1/5]
# in the region 3, there are 3 cantons and each canton is selected with the prob. 1/3[在区域3中,有3个州和每个州被选择的概率。三分之一]
# in the region 4, there is 1 canton, which it is selected with the prob. 1[在区域4中的,有1个州,它被选择的概率。 1]
# in the region 5, there are 7 cantons and each canton is selected with the prob. 1/7[在区域5,有7个州,每个州被选择的概率。 1/7]
# in the region 6, there are 6 cantons and each canton is selected with the prob. 1/6[的区域6中,有6个州和每个州被选择的概率。 1/6]
# in the region 7, there is 1 canton, which it is selected with the prob. 1[的区域7中,有1个州,它被选择的概率。 1]
# it is necessary to use a list of selection probabilities at each stage[在每个阶段,有必要使用的列表的选择概率]
# prob is the list of the selection probabilities[概率是列表的选择概率]
# the method is systematic sampling (unequal probabilities, without replacement)[系统抽样的方法是(不等概率,无需更换)]
# 4 clusters (regions) are drawn in the first-stage [4个簇(区域)是在第一阶段的绘制]
# 1 cluster (canton) is drawn in the second-stage from each selected region [1簇(州)绘制在第二阶段,从每个选定的区域]
# ls is the list of sizes[ls是的尺寸列表]
ls=list(4,c(1,1,1,1))
prob=list(rep(4/7,7),list(rep(1/3,3),rep(1/5,5),rep(1/3,3),rep(1,1),rep(1/7,7),
rep(1/6,6),rep(1,1)))
m=mstage(swissmunicipalities,stage=list("cluster","cluster"),varnames=list("REG","CT"),
size=ls, method="systematic",pik=prob)
# extracts the observed data[提取所观察到的数据]
getdata(swissmunicipalities,m)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-29 04:51 , Processed in 0.023562 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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