stata陈强:第四章 stata操作基础

高级计量经济学及stata应用 陈强

第四章 stata简介

本章课本代码

clear all 

cd "F:\stata经济数据分析"
dir
use nerlove.dta

describe

* label data
label data "Nerlove 1963 paper"

* list 
list tc q 
list tc q in 1/5
list tc q in 32/36
list 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 def 1 lnpl+lnpk+lnpf = 1
cnsreg lntc lnq lnpl lnpk lnpf ,c(1)

constraint def 2 lnq = 1
cnsreg lntc lnq lnpl lnpk lnpf ,c(1-2)

* 11.log ******

* the difference 
* e-class commands (estimation commands) / r-class commands

* example about r-class commands 
* using return list to show more about it 
summarize q
return list

* display coefficient of variation
display r(sd)/r(mean)

display "coefficient of variation is " r(sd)/r(mean)

* example about e-class commands (estimation commands)
* using ereturn list to show more about it 
reg tc q2
ereturn list
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值