全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
8275 1
2011-12-23
出入统计行业,由于大学没学统计学,所以算是一个彻头彻尾的门外汉。请教各位一些问题啊。
服务业抽样程序如下:
/****************整理抽样框,选择行业代码****************/
use "F:\服务业\数据\抽样过程\52_cyk1.dta", clear
gen random=uniform()                                                                                
gen str2 hydl=substr(hydm,1,2)
keep if hydl="52"
save 52_cyk1.dta,replace

/****************抽取必调层****************/
use "F:\服务业\数据\抽样过程\52_cyk1.dta", clear
table hydl,c(freq) row
table hydl,c(mean yysr sd yysr min yysr max yysr sum yysr) format(%10.0f) row
drop if yysr<30000
table hydl,row
gen fc=99
gen str8 code=hydl+string(fc)
sort code                                                                                
by code:gen bign=_N                                                                        
by code:gen n=_N                                                        
gen weight=bign/n
sort frdm
save 52_b.dta,replace

/****************保留非必调查层****************/
use "F:\服务业\数据\抽样过程\52_cyk1.dta", clear                                                               
sort frdm                                                                                       
merge frdm using 52_b.dta
drop if _merge==3
drop _merge
save 52_f.dta,replace                                                        

/****************累计平方根确定分层界限****************/
use 52_f.dta,replace
local zs=300                                                                                       
local zj=100                                                                                       
use "F:\服务业\数据\抽样过程\52_cyk1.dta", clear
gen No=0        
forvalue i=1/`zs'{                                                                        
local point=`zj'*(`i'-1)
replace No=`i' if yysr>=`point'
}
table No,replace                                                                                
rename table1 freq
gen sqrt=sqrt(freq)
gen comulatesqrt=sum(sqrt)                                                                        
edit                                                                                                   

/****************对非必调查层分层****************/
use 52_f.dta, clear
replace fc=1
replace fc=2 if yysr>2400
replace fc=3 if yysr>8200
replace code=hydl+string(fc)+"0"
table hydl fc,row col
save 52_f.dta,replace

/***************非必调查层样本分配****************/
use 52_f.dta, clear
sort code
by code:replace bign=_N
replace n=27 if code=="5210"
replace n=26 if code=="5220"
replace n=26 if code=="5230"
replace weight=bign/n
save 52_f.dta,replace

/***************必调查层和非必调查层合并****************/
use 52_b.dta, clear
append using 52dlys01_f
save 52_cyk_2.dta

/***************样本抽取****************/
use 52_cyk_2.dta,clear
gsort code random
by code:keep if _n<=n
save 52.dta,replace

/**************反测精度****************/
use 52.dta,clear
svyset strata code
svyset pweight weight
svyset fpc bign
svytotal yysr cyrs zczj zysr
keep in 1
matrix a1=e(b)
matrix a2=e(V)
gen yysrest=a1[1,1]
gen yysrxdw=1.96*sqrt(a2[1,1])/a1[1,1]*100
gen cyrsest=a1[1,2]
gen cyrsxdw=1.96*sqrt(a2[2,2])/a1[1,2]*100
gen zczjest=a1[1,4]
gen zczjxdw=1.96*sqrt(a2[4,4])/a1[1,4]*100
gen zysrest=a1[1,6]
gen zysrxdw=1.96*sqrt(a2[6,6])/a1[1,6]*100
keep yysrest yysrxdw cyrsest cyrsxdw zczjest zczjxdw zysrest zysrxdw
save 52.dta,replace

最后部分反测精度实在看不懂,svyset是怎么用的?那些公式又是怎么计算精度的?help svyset看不太懂。。。
跪求解释呀。。

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-12-30 13:30:24
svyset declares the data to be complex survey data, designates variables that contain information about the survey design, and specifies the default method for variance estimation.  You must svyset your data before using any svy  command;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群