简单估计比较样本均值和总体均值:
二、分层随机抽样
attach(wind)
for(i in 1:N){
if (wind[i,2]>201000 && wind[i,2]<201100) wind[i,2]=1
if (wind[i,2]>201100 && wind[i,2]<201200) wind[i,2]=2
if (wind[i,2]>201200 && wind[i,2]<201300) wind[i,2]=3
if (wind[i,2]>201300 && wind[i,2]<201400) wind[i,2]=4
if (wind[i,2]>201400 && wind[i,2]<201500) wind[i,2]=5
if (wind[i,2]>201500 && wind[i,2]<201600) wind[i,2]=6
} #将数据按照年份(变量名为 month)分成六类
wind$month=factor(wind$month,levels=as.character(1:6))
wh=n*table(wind$month)/N
o=order(wind$month)
srp=strata(data=wind[o,],stratanames="month",size=wh,method="
srswor") #分层抽样
sr=getdata(wind,srp) #入选样本
三、整群抽样
scp=cluster(data=wind,clustername="trade_code",size=10,method
="srswor",description=FALSE)
sc=getdata(wind,scp)
四、系统抽样
评论1
最新资源