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

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

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

                                        The ratio estimator for a stratified design
                                         比估计的分层设计

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

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

Computes the ratio estimator of the population total for a stratified design.
计算比率估计人口总数的分层设计。


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


ratioest_strata(y,x,TX_strata,pik,strata,description=FALSE)



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

参数:y
vector of the variable of interest; its length is equal to n, the sample size.
感兴趣的变量的矢量,其长度为n,样本大小是相等的。


参数:x
vector of auxiliary information; its length is equal to n, the sample size.
的辅助信息的矢量,它的长度是相等的,样本大小为n。


参数:TX_strata
vector of population x-total in each stratum; its length is equal to the number of strata.
人口x总在各阶层的向量,它的长度是等于地层的数目。


参数:pik
vector of the first-order inclusion probabilities; its length is equal to n, the sample size.
的一阶包含概率的向量,它的长度是相等的,样本大小为n。


参数:strata
vector of size n, with elements indicating the unit stratum.
矢量的大小为n,表示单位阶层的元素。


参数:description
if TRUE, the ratio estimator in each stratum is printed; by default, it is FALSE.
如果为TRUE,各阶层的比例估计在打印,默认情况下,它是FALSE。


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

The function returns the value of the ratio estimator.
该函数返回值的比率估计。


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

ratioest
ratioest


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


###########[##########]
# Example 1[例1]
###########[##########]
# this example uses MU284 data with the 'REG' variable for stratification[本例中使用“REG”变量进行分层MU284数据]
data(MU284)
attach(MU284)
# there are 3 outliers which are deleted from the population[有3个离群的人口被删除]
MU281=MU284[RMT85<=3000,]
detach(MU284)
attach(MU281)
# computes the inclusion probabilities using the variable P85[计算使用可变P85包含概率]
pik=inclusionprobabilities(P85,120)
# defines the variable of interest[定义变量的兴趣]
y=RMT85
# defines the auxiliary information[定义的辅助信息]
x=CS82
# computes the population stratum sizes[计算人口阶层大小]
table(MU281$REG)
# not run[不运行]
# 1  2  3  4  5  6  7  8 [1 2 3 4 5 6 7 8]
# 24 48 32 37 55 41 15 29 [24 48 32 37 55 41 15 29]
# a sample is drawn in each region[样品在每个区域绘制]
# the sample stratum sizes are given by size=c(4,10,8,4,6,4,6,7)[样品层的大小给定的的规模= C(4,10,8,4,6,4,6,7)]
s=strata(MU281,c("REG"),size=c(4,10,8,4,6,4,6,7), method="systematic",pik=P85)
# extracts the observed data[提取所观察到的数据]
MU281sample=getdata(MU281,s)
# computes the population x-totals in each stratum[X-总额计算的人口各阶层]
TX_strata=as.vector(tapply(CS82,list(REG),FUN=sum))
# computes the ratio estimator[计算的比率估计]
ratioest_strata(MU281sample$RMT85,MU281sample$CS82,TX_strata,
MU281sample$Prob,MU281sample$Stratum)
###########[##########]
# Example 2[例2]
###########[##########]
# this is an artificial example (see Example 1 in the 'strata' function)[这是一个人为的例子(参见实施例1的“地层”功能)]
# there are 4 columns: state, region, income and aux[有4列:国家,区域,收入和辅助]
# 'income' is the variable of interest, and 'aux' is the auxiliary information [“收入”是可变的兴趣,“AUX”是辅助信息]
# which is correlated to the income[这是相关的收入]
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")
attach(data)
aux=income+rnorm(length(income),0,1)
data=cbind.data.frame(data,aux)
# 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; one draws 5 samples (1 sample in each stratum)[非零值有5个单元,一个绘制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[提取所观察到的数据]
xx=getdata(data,s)
# computes the population x-total for each stratum[计算各阶层总人口的X-]
TX_strata=na.omit(as.vector(tapply(aux,list(region,state),FUN=sum)))
# computes the ratio estimator [计算的比率估计]
ratioest_strata(xx$income,xx$aux,TX_strata,xx$Prob,xx$Stratum,description=TRUE)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-29 06:37 , Processed in 0.026659 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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