學(xué)習(xí)筆記FE&RE(其一)

> 天鷹(中南財大——博士研究生)

E-mail: yanbinglh@163.com

對于固定效應(yīng)以及隨機(jī)效應(yīng)模型的選擇一直是學(xué)習(xí)面板的難點,stata的操作是很簡單的,但是對于理論模型的選擇問題還是有必要弄清楚背后的理論基礎(chǔ)的,這篇文章也僅僅是對于相應(yīng)操作的一個簡單總結(jié),理論部分還是需要仔細(xì)閱讀課本的。(數(shù)據(jù)來源:陳強(qiáng)高級計量經(jīng)濟(jì)學(xué))


use traffic.dta,clear

xtset state year? ///設(shè)定個體變量和時間變量

panel variable:? state (strongly balanced)

time variable:? year, 1982 to 1988

delta:? 1 unit

xtdes? ///顯示數(shù)據(jù)集結(jié)構(gòu)


xtsum ? ///顯示變量特征的命令

xtsum fatal beertax spircons unrate perinck state year///顯示數(shù)據(jù)集的變量特征


xtline fatal? ///查看變量的時間趨勢圖


混合回歸

reg y x1 x2 x3,vce(cluster id ) ///id用來確定每個個體的變量

reg fatal beertax spircons unrate perinck ,vce(cluster state)


estimates store OLS? ? ///回歸結(jié)果的儲存

reg fatal beertax spircons unrate perinck? ///這個回歸結(jié)果是使用普通標(biāo)準(zhǔn)誤


固定效應(yīng)

xtreg fatal beertax spircons unrate perinck ,fe r? ///使用固定效應(yīng)模型


estimates store FE_robust

xtreg fatal beertax spircons unrate perinck ,fe? ///不加r時輸出的結(jié)果包含一個F檢驗


estimates store FE

進(jìn)一步通過LSDV(最小二乘虛擬變量)來考察

?reg fatal beertax spircons unrate perinck i.state,vce(cluster state)


estimates store FD

也可以在固定效應(yīng)中考慮時間效應(yīng),即雙向固定效用

tab year ,gen(year)? ///定義年度虛擬變量


xtreg fatal beertax spircons unrate perinck year2-year7,fe r

estimates store FE_TW


xtreg fatal beertax spircons unrate perinck i.year,fe r? ///這個命令可以直接估計雙向固定效應(yīng)


隨機(jī)效應(yīng)

xtreg y x1 x2 x3,re r theta ///隨機(jī)效應(yīng)FGLS

xtreg y x1 x2 x3,mle? ? ? ? ///隨機(jī)效應(yīng)MLE

xtreg fatal beertax spircons unrate perinck ,re r theta


estimates store RE

xttest0? ///LM檢驗的命令在執(zhí)行完xtreg,re后才可以執(zhí)行


xtreg fatal beertax spircons unrate perinck ,mle nolog? ///對隨機(jī)效應(yīng)模型進(jìn)行MLE估計


estimates store MLE

組間估計量(BE)

xtreg fatal beertax spircons unrate perinck ,be? ///組間估計


estimates store BE

固定效應(yīng)還是隨機(jī)效應(yīng)的判斷:豪斯曼檢驗

hausman FE RE,constant sigmamore

hausman cannot be used with vce(robust), vce(cluster cvar), or p-weighted data

r(198);? ///豪斯曼檢驗時,如果使用聚類穩(wěn)健標(biāo)準(zhǔn)誤,命令無法執(zhí)行

xtreg fatal beertax spircons unrate perinck ,fe

estimates store FE

xtreg fatal beertax spircons unrate perinck ,re

estimates store RE

hausman FE RE,constant sigmamore


檢驗結(jié)果顯示強(qiáng)烈拒絕原假設(shè)H0:ui與xit,zi不相關(guān),應(yīng)該使用固定效應(yīng)模型

如果聚類標(biāo)準(zhǔn)誤與普通的標(biāo)準(zhǔn)誤誤差較大,那么傳統(tǒng)的豪斯曼檢驗將不再適用

解決的辦法是使用自助法或者進(jìn)行輔助回歸

quietly? xtreg fatal beertax spircons unrate perinck ,re

scalar theta=e(theta)

global yandxforhausman? fatal beertax spircons unrate perinck? ///全局宏

sort state

foreach x of varlist $yandxforhausman{

? 2. by state:egen mean`x'=mean(`x')

? 3. gen md`x'=`x'-mean`x'

? 4. gen red`x'=`x'-theta*mean`x'

? 5. }

quietly reg redfatal redbeertax redspircons redunrate redperinck mdbeertax mdspircons mdunrate mdperinck ,vce(cluster state)

test mdbeertax mdspircons mdunrate mdperinck


拒絕隨機(jī)效應(yīng),選擇固定效應(yīng)

也可使用下列外部命令進(jìn)行輔助回歸

ssc install xtoverid

?quietly? xtreg fatal beertax spircons unrate perinck ,re? r

xtoverid


匯總以上各種方法的估計系數(shù)以及標(biāo)準(zhǔn)誤列表

estimates table OLS FE_robust FE_TW RE BE ,b se? ///要學(xué)會這個命令


不同的系數(shù)估計方法估計系數(shù)差別較大

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 靜態(tài)面板數(shù)據(jù)的主要問題 橫截面異方差 序列自相關(guān) 橫截面同期相關(guān) 基礎(chǔ)工作 屢次失敗的經(jīng)驗表明,洗數(shù)據(jù)和看數(shù)據(jù)是非...
    CHEN_DIANDIAN閱讀 27,114評論 0 16
  • > 天鷹(中南財大——博士研究生) E-mail: yanbinglh@163.com 雙重差分模型的平行趨勢假定...
    天鷹_2019閱讀 8,367評論 0 4
  • 夜鶯2517閱讀 128,103評論 1 9
  • 我是黑夜里大雨紛飛的人啊 1 “又到一年六月,有人笑有人哭,有人歡樂有人憂愁,有人驚喜有人失落,有的覺得收獲滿滿有...
    陌忘宇閱讀 8,822評論 28 54
  • 信任包括信任自己和信任他人 很多時候,很多事情,失敗、遺憾、錯過,源于不自信,不信任他人 覺得自己做不成,別人做不...
    吳氵晃閱讀 6,361評論 4 8

友情鏈接更多精彩內(nèi)容