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

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

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

                                        Sample cube method
                                         示例立方体方法

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

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

Selects a balanced sample (a vector of 0 and 1) or an almost balanced sample. Firstly, the flight phase is applied. Next, if needed, the landing phase is applied on the result of the flight phase.
选择均衡的样本(0和1)的向量或几乎均衡的样本。首先被施加的飞行阶段。接着,如果需要的话,着陆阶段施加在飞行阶段的结果。


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


samplecube(X,pik,order=1,comment=TRUE,method=1)



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

参数:X
matrix of auxiliary variables on which the sample must be balanced.
该样本必须是平衡的辅助变量的矩阵。


参数:pik
vector of inclusion probabilities.
矢量包含概率。


参数:order
1, the data are randomly arranged,<br> 2, no change in data order,<br> 3, the data are sorted in decreasing order.  
数据1,数据是随机排列,参考2,没有变化的数据的顺序,参考3,以递减的顺序进行排序。


参数:comment
a comment is written during the execution if comment is TRUE.
在执行过程中如果comment是TRUE写评论。


参数:method
1, for a landing phase by linear programming,<br> 2, for a landing phase by suppression of variables.
如图1所示,通过线性规划,参考2,为着陆阶段通过抑制变量为着陆阶段。


参考文献----------References----------

Chauvet, G. and Till茅, Y. (2006). A fast algorithm of balanced sampling. Computational Statistics, 21/1:53&ndash;62. <br> Chauvet, G. and Till茅, Y. (2005). New SAS macros for balanced sampling. In INSEE, editor, Journ茅es de M茅thodologie Statistique, Paris.<br> Deville, J.-C. and Till茅, Y. (2004). Efficient balanced sampling: the cube method. Biometrika, 91:893&ndash;912.<br> Deville, J.-C. and Till茅, Y. (2005). Variance approximation under balanced sampling. Journal of Statistical Planning and Inference, 128/2:411&ndash;425.

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

landingcube, fastflightcube
landingcube,fastflightcube


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


############[###########]
## Example 1[#示例1]
############[###########]
# matrix of balancing variables[矩阵的平衡变量]
X=cbind(c(1,1,1,1,1,1,1,1,1),c(1.1,2.2,3.1,4.2,5.1,6.3,7.1,8.1,9.1))
# vector of inclusion probabilities[包含概率向量]
# the sample size is 3.[样本大小为3。]
pik=c(1/3,1/3,1/3,1/3,1/3,1/3,1/3,1/3,1/3)
# selection of the sample[样品的选择]
s=samplecube(X,pik,order=1,comment=TRUE)
# The selected sample[所选样本]
(1:length(pik))[s==1]
############[###########]
## Example 2[#示例2]
############[###########]
# 2 strata and 2 auxiliary variables[2地层和2个辅助变量]
# we verify the values of the inclusion probabilities by simulations[我们通过仿真验证的值包含概率]
X=rbind(c(1,0,1,2),c(1,0,2,5),c(1,0,3,7),c(1,0,4,9),
c(1,0,5,1),c(1,0,6,5),c(1,0,7,7),c(1,0,8,6),c(1,0,9,9),
c(1,0,10,3),c(0,1,11,3),c(0,1,12,2),c(0,1,13,3),
c(0,1,14,6),c(0,1,15,8),c(0,1,16,9),c(0,1,17,1),
c(0,1,18,2),c(0,1,19,3),c(0,1,20,4))
pik=rep(1/2,times=20)
ppp=rep(0,times=20)
sim=100 #for accurate results increase this value[准确的结果增加值]
for(i in (1:sim))
        ppp=ppp+samplecube(X,pik,1,FALSE)
ppp=ppp/sim
print(ppp)
print(pik)
############[###########]
## Example 3[#示例3]
############[###########]
# unequal probability sampling by cube method[立方体不等概率抽样的方法]
# one auxiliary variable equal to the inclusion probability[一个辅助变量等于包含概率]
N=200
pik=runif(N)
pikfin=samplecube(array(pik,c(N,1)),pik,1,TRUE)
############ [###########]
## Example 4[#例4]
############[###########]
# p auxiliary variables generated randomly[p辅助变量随机产生]
N=1000
p=7
x=rnorm(N*p,10,3)
# random inclusion probabilities [随机列入概率的]
pik= runif(N)
X=array(x,c(N,p))
X=cbind(cbind(X,rep(1,times=N)),pik)
pikfin=samplecube(X,pik,1,TRUE)
############ [###########]
## Example 5[#例5]
############[###########]
# strata and an auxiliary variable[阶层和辅助变量]
N=5000
a=rep(1,times=N)
b=rep(0,times=N)
V1=c(a,b,b)
V2=c(b,a,b)
V3=c(b,b,a)
X=cbind(V1,V2,V3)
pik=rep(2/10,times=3*N)
pikfin=samplecube(X,pik,1,TRUE)
############[###########]
## Example 6[#例6]
############[###########]
# Selection of a balanced sample using the MU284 population,[选择一个平衡样本使用MU284人口,]
# simulation and comparison of the variance with[模拟和比较的方差与]
# unequal probability sampling of fixed sample size.[固定样本量的不等概率抽样。]
############[###########]
data(MU284)
# Computation of the inclusion probabilities[包含概率的计算]
pik=inclusionprobabilities(MU284$P75,50)
# Definition of the matrix of balancing variables[的平衡变量矩阵定义]
X=cbind(MU284$P75,MU284$CS82,MU284$SS82,MU284$S82,MU284$ME84,MU284$REV84)
# Computation of the Horvitz-Thompson estimator for a balanced sample[计算一个平衡的样品的的霍维茨-Thompson估计]
s=samplecube(X,pik,1,FALSE)
HTestimator(MU284$RMT85[s==1],pik[s==1])
# Computation of the Horvitz-Thompson estimator for an unequal probability sample[计算的不等概率抽样的的霍维茨-Thompson估计]
s=samplecube(matrix(pik),pik,1,FALSE)
HTestimator(MU284$RMT85[s==1],pik[s==1])
# simulations; for a better accurancy, increase the value of 'sim'[模拟一个更好的之准确度,增加值的SIM“]
sim=8
res1=rep(0,times=sim)
res2=rep(0,times=sim)
for(i in 1:sim)
{
cat("Simulation number ",i,"\n")
s=samplecube(X,pik,1,FALSE)
res1[i]=HTestimator(MU284$RMT85[s==1],pik[s==1])
s=samplecube(matrix(pik),pik,1,FALSE)
res2[i]=HTestimator(MU284$RMT85[s==1],pik[s==1])
}
# summary and boxplots[总结和盒状图]
summary(res1)
summary(res2)
ss=cbind(res1,res2)
colnames(ss) = c("balanced sampling","uneq prob sampling")
boxplot(data.frame(ss), las=1)

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


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

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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