clear all
cd "F:\stata经济数据分析"dir
use nerlove.dta
describe
* label data
label data "Nerlove 1963 paper"*listlist tc q
list tc q in1/5list tc q in32/36list tc q if q>=10000* delete
drop if q >=10000* summarize
summarize q
summarize q if q >=10000
summarize q , detail
* 显示经验累积分布函数 empirical cumulative distribution function
tabulate pl
pwcorr pl pf pk , sig star(.05)* picture
*1 histogram
histogram q , width(1000) frequency
*2 kdensity
kdensity q
*3 scatter
scatter tc q
gen n = _n
scatter tc q , mlabel(n) mlabpos(6)
twoway (scatter tc q)(lfit tc q)
graph save scatter1
twoway (scatter tc q)(qfit tc q)
graph save scatter2
graph combine scatter1.gph scatter2.gph
* example cobb-douglas
g lntc = log(tc)
g lnq = log(q)
g lnpl = log(pl)
g lnpf = log(pf)
g lnpk = log(pk)
g q2 = q^2
g lnplpk = lnpl*lnpk
g large =(q>=60000)* calculater
display log(2)
display normal(1.96)* linear regress
regress lntc lnq lnpl lnpk lnpf
vce // variance covariance matrix estimated
regress lntc lnq lnpl lnpk lnpf, noconstant
regress lntc lnq lnpl lnpk lnpf if q>=6000
regress lntc lnq lnpl lnpk lnpf if large ==1
regress lntc lnq lnpl lnpk lnpf if large ==0* predict ***
predict intchat
predict e1 ,residual
display 1/_b[lnq]* H0: r=1
test lnq =1
test (lnq=1)(lnpl+lnpk+lnpf=1)
test lnpl lnpk
testnl _b[lnpl]=_b[lnq]^2
avplot lnq
avplots
* constraint regress
* cnsreg: constrained regression
* example
constraint def1 lnpl+lnpk+lnpf =1
cnsreg lntc lnq lnpl lnpk lnpf ,c(1)
constraint def2 lnq =1
cnsreg lntc lnq lnpl lnpk lnpf ,c(1-2)*11.log ******* the difference
* e-classcommands(estimation commands)/ r-classcommands* example about r-classcommands* using returnlist to show more about it
summarize q
returnlist* display coefficient of variation
display r(sd)/r(mean)
display "coefficient of variation is " r(sd)/r(mean)* example about e-classcommands(estimation commands)* using ereturn list to show more about it
reg tc q2
ereturn list
高级计量经济学及stata应用 陈强第四章 stata简介本章课本代码第四章 stata简介本章课本代码clear all cd "F:\stata经济数据分析"diruse nerlove.dtadescribe* label datalabel data "Nerlove 1963 paper"* list list tc q list tc q in 1/5list tc q in 32/36list tc q if q>=10000* deletedr