空間面板主要命令為:help xsmle
helpxsmle
net?install?xsmle,all?from?()
Requirements:Stata?Version?10Data?must?be?tsset?or?xtset
相關(guān)操作案例代碼為:
#?計(jì)量經(jīng)濟(jì)學(xué)服務(wù)中心空間計(jì)量課程
cdE:\stata\data???????????//設(shè)置工作路徑翘魄,調(diào)用數(shù)據(jù)
use?product.dta,?clear
該數(shù)據(jù)為包含美國(guó)48個(gè)州的如下變量簇抵,gsp州產(chǎn)出比勉,pcap公共資本坦胶,pc民營(yíng)資本桑包,emp就業(yè)量宠纯,unemp失業(yè)率伐坏。
Gsp州產(chǎn)出?(gross?state?product)
pcap公共資本(public?captial)
pc民營(yíng)資本(private?captial)
emp就業(yè)量(employment)
unemp失業(yè)率(unemployment?rate)
由于產(chǎn)出禀综、資本和就業(yè)量存在指數(shù)增長(zhǎng)趨勢(shì)掠廓,故需要對(duì)這些變量取對(duì)數(shù)
相關(guān)操作案例代碼為:
#?計(jì)量經(jīng)濟(jì)學(xué)服務(wù)中心空間計(jì)量課程
gen?lngsp?=log(gsp)
gen?lnpcap?=log(pcap)
gen?lnpc?=log(pc)
gen?lnemp?=log(emp)
spmat?use?usaww?using?usaww.spmat
表示根據(jù)文件usaww.spmat來(lái)生成空間權(quán)重矩陣usaww换怖,參見(jiàn)help spmat
本文首先生成地區(qū)以及時(shí)間相關(guān)的虛擬變量,首先設(shè)置48個(gè)州全部數(shù)據(jù)為1980-1986年為受到政策實(shí)施干預(yù)蟀瞧,此時(shí)時(shí)間虛擬變量t=1沉颂,而1970-1979年為0
另外設(shè)置前面20個(gè)州的數(shù)據(jù)為受到政策干預(yù)的州的組別,變量為code悦污,最后生成spdid铸屉,spdid為t*code的交互項(xiàng)
三、雙重差分空間滯后模型
#??計(jì)量經(jīng)濟(jì)學(xué)服務(wù)中心空間計(jì)量課程
*========================================
*???????????高級(jí)計(jì)量經(jīng)濟(jì)學(xué)
*========================================
*????????計(jì)量經(jīng)濟(jì)學(xué)服務(wù)中心
*
*???????===================================
*??????????空間計(jì)量及Stata應(yīng)用(1)
*???????===================================
*-------------------------------------------------------------------------------
*????????參考資料:
*????????《初級(jí)計(jì)量經(jīng)濟(jì)學(xué)及Stata應(yīng)用:Stata從入門到進(jìn)階》
*????????《高級(jí)計(jì)量經(jīng)濟(jì)學(xué)及Stata應(yīng)用:Stata回歸分析與應(yīng)用》
*????????《高級(jí)計(jì)量經(jīng)濟(jì)學(xué)及Eviews應(yīng)用》
*????????《空間計(jì)量入門》
*????????《零基礎(chǔ)|輕松搞定空間計(jì)量:空間計(jì)量及GeoDa切端、Stata應(yīng)用》
*????????《空間計(jì)量第二部:空間計(jì)量及Matlab應(yīng)用課程》
*????????《空間計(jì)量第三部:空間計(jì)量及Stata應(yīng)用課程》
*????????《空間計(jì)量第四部:《空間計(jì)量及ArcGis應(yīng)用課程》
*????????《空間計(jì)量第五部:空間計(jì)量經(jīng)濟(jì)學(xué)》
*????????《空間計(jì)量第六部:《空間計(jì)量及Python應(yīng)用》
*????????《空間計(jì)量第七部:《空間計(jì)量及R應(yīng)用》
*????????《空間計(jì)量第八部:《高級(jí)空間計(jì)量經(jīng)濟(jì)學(xué)》
*-------------------------------------------------------------------------------
*-------------------------------------------------------------------------------
*一梦重、數(shù)據(jù)生成
*-------------------------------------------------------------------------------
cdE:\stata\data
use?product.dta,clear
*1抚芦、生成時(shí)間虛擬變量
gene?t=0
ed
replace?t=1in1/340
ed
*2锰什、生成地區(qū)虛擬變量
gene?code=0
replace?code=1ifyear>=1980?&?year?<=1986
*3、生成時(shí)間空間交互項(xiàng)
gene?spdid=t*code
*-------------------------------------------------------------------------------
*二线梗、數(shù)據(jù)生成
*-------------------------------------------------------------------------------
*4、數(shù)據(jù)對(duì)數(shù)轉(zhuǎn)換
gen?lngsp?=log(gsp)
gen?lnpcap?=log(pcap)
gen?lnpc?=log(pc)
gen?lnemp?=log(emp)
*5怠益、生成空間權(quán)重矩陣
spmat?use?usaww?using?usaww.spmat
*6仪搔、面板數(shù)據(jù)設(shè)定
xtset?state?year
*7、雙重差分空間滯后模型
xsmle?lngsp?lnpcap?lnpc?lnemp?spdid?t?code?,?fe?model(sac)?wmat(usaww)?emat(usaww)
結(jié)果為:
.
.?*-------------------------------------------------------------------------------
.?*一蜻牢、數(shù)據(jù)生成
.?*-------------------------------------------------------------------------------
.
.cdE:\stata\data
E:\stata\data
.
.?use?product.dta,clear
.
.?*1烤咧、生成時(shí)間虛擬變量
.?gene?t=0
.?ed
.?replace?t=1in1/340
(340?real?changes?made)
.?ed
.
end?ofdo-file
.do"C:\Users\admin\AppData\Local\Temp\STD1f44c_000000.tmp"
.
.?*2、生成地區(qū)虛擬變量
.?gene?code=0
.?replace?code=1ifyear>=1980?&?year?<=1986
(336?real?changes?made)
.
.
.?*3抢呆、生成時(shí)間空間交互項(xiàng)
.?gene?spdid=t*code
.
end?ofdo-file
.do"C:\Users\admin\AppData\Local\Temp\STD1f44c_000000.tmp"
.
.?*-------------------------------------------------------------------------------
.?*二煮嫌、數(shù)據(jù)生成
.?*-------------------------------------------------------------------------------
.?*4、數(shù)據(jù)對(duì)數(shù)轉(zhuǎn)換
.?gen?lngsp?=log(gsp)
.?gen?lnpcap?=log(pcap)
.?gen?lnpc?=log(pc)
.?gen?lnemp?=log(emp)
.
end?ofdo-file
.do"C:\Users\admin\AppData\Local\Temp\STD1f44c_000000.tmp"
.
.?*5抱虐、生成空間權(quán)重矩陣
.?spmat?use?usaww?using?usaww.spmat
.
.?*6昌阿、面板數(shù)據(jù)設(shè)定
.?xtset?state?year
Panel?variable:?state?(strongly?balanced)
Time?variable:?year,?1970?to?1986
Delta:?1?unit
.
.?*7、雙重差分空間滯后模型
.
.?xsmle?lngsp?lnpcap?lnpc?lnemp?spdid?t?code?,?fe?model(sac)?wmat(usaww)?emat(usaww)
Iteration?0:???Log-likelihood?=??1544.8042
Iteration?1:???Log-likelihood?=??1562.4899
Iteration?2:???Log-likelihood?=??1617.9469
Iteration?3:???Log-likelihood?=??1640.9464
Iteration?4:???Log-likelihood?=??1645.2944
Iteration?5:???Log-likelihood?=??1645.3607
Iteration?6:???Log-likelihood?=??1645.3607
SAC?with?spatial?fixed-effects???????????????????????Number?of?obs?=???????816
Group?variable:?state?????????????????????????????Number?of?groups?=????????48
Time?variable:?year???????????????????????????????????Panel?length?=????????17
R-sq:????within??=?0.9406
between?=?0.9857
overall?=?0.9846
Mean?of?fixed-effects?=??2.9531
Log-likelihood?=??1645.3607
------------------------------------------------------------------------------
lngsp?|?Coefficient??Std.?err.??????z????P>|z|?????[95%?conf.?interval]
-------------+----------------------------------------------------------------
Main?????????|
lnpcap?|??-.0270419???.0248934????-1.09???0.277????-.0758322????.0217483
lnpc?|???.1611582???.0243781?????6.61???0.000?????.1133779????.2089384
lnemp?|???.7869296????.025797????30.50???0.000?????.7363685????.8374908
spdid?|??-.0186175???.0042006????-4.43???0.000????-.0268505???-.0103846
t?|??????????0??(omitted)
code?|???.0179788???.0073538?????2.44???0.014?????.0035657????.0323919
-------------+----------------------------------------------------------------
Spatial??????|
rho?|???.0589165???.0324815?????1.81???0.070????-.0047461?????.122579
lambda?|???.5149828???.0466917????11.03???0.000?????.4234688????.6064967
-------------+----------------------------------------------------------------
Variance?????|
sigma2_e?|???.0010233???.0000497????20.57???0.000?????.0009259????.0011208
------------------------------------------------------------------------------
.
end?ofdo-file
.