來源:綜合整理自:http://dss./training/ 轉(zhuǎn)載請注明來源 運行固定/隨機(jī)效應(yīng)的Stata命令是xtreg。使用前xtreg您需要使用以下命令設(shè)置Stata來處理面板數(shù)據(jù)xtset。 xtset country year 結(jié)果為: 在這種情況下'county'代表實體或小組(i),“year”表示時間變量(t)。 注意”(強烈平衡)指的是所有國家都擁有所有年份的數(shù)據(jù)。例如,如果一個國家一年內(nèi)沒有數(shù)據(jù),那么數(shù)據(jù)就是不平衡的。理想情況下,您希望有一個平衡的數(shù)據(jù)集,但這并不總是但是,您仍然可以運行模型。 注意事項:如果在使用xtset后出現(xiàn)以下錯誤: varlist: country: string variable not allowed 解決方案為: encode country, gen(country1) 在xtset命令中使用“country1”而不是“country” 需要使用數(shù)值型類型
結(jié)果為: 如果放在一張圖里面,操作為 xtline y, overlay 結(jié)果為:
xi: regress y x1 i.country
xtreg y x1, fe 注意和下面對比系數(shù)
固定效應(yīng)結(jié)果統(tǒng)計量解釋 其中: y表示Outcomevariable x1表示Predictor variable(s) Number of obs 表示Total number of cases (rows) Number of groups Total number of groups (entities) F(1,62) = 5.00,Prob > F如果這個數(shù)字< 0.05,那么您的模型就可以了。這是一個檢驗(F),看看模型中的所有系數(shù)是否都不為零。 corr(u_i, Xb) = -0.5468 表示ui與解釋變量的相關(guān)性 t值檢驗各系數(shù)為不同于0的假設(shè) 。要拒絕它,t值必須高于1.96(95%可信)。如果這在這種情況下,你可以說變量對因變量有顯著影響,t值越高,變量的相關(guān)性越高。 雙尾p值測試:假設(shè)每個系數(shù)不等于0。為了拒絕這個,p值需要小于0.05 (95%) areg y x1, absorb(country) 結(jié)果為:
結(jié)果為: 對比上述固定效應(yīng)操作結(jié)果 xtreg y x1 x2 x3, fe estimates store fixed xi: regress y x1 x2 x3 i.country estimates store ols areg y x1 x2 x3, absorb(country) estimates store areg estimates table fixed ols areg, star stats(N r2 r2_a) 結(jié)果為: 隨機(jī)操作操作
結(jié)果為: 隨機(jī)操作操作 xtreg y x1, fe estimates store fixed xtreg y x1, re estimates store random hausman fixed random 結(jié)果為: chi2(1) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 3.67 ,Prob>chi2 = 0.0553,If P值this is < 0.05 (i.e. significant) use fixed effects. Testing for time-fixed effects 看看是否需要 時間固定效果,運行FE模型時使用 命令testparm 。
結(jié)果為: Testing for random effects: Breusch-Pagan Lagrange multiplier (LM) xtreg y x1, re xttest0 橫斷面相關(guān)性/同期相關(guān)性檢驗:
異方差檢驗檢驗: ssc install xtest3 xttest3 序列相關(guān)檢驗 系列相關(guān)測試適用于的長面板數(shù)據(jù)(20-30年以上)。
|
|