来源:综合整理自:http://dss./training/ 转载请注明来源 运行固定/随机效应的Stata命令是xtreg。使用前xtreg您需要使用以下命令设置Stata来处理面板数据xtset。 xtset country year 结果为: 在这种情况下'county'代表实体或小组(i),“year”表示时间变量(t)。 注意”(强烈平衡)指的是所有国家都拥有所有年份的数据。例如,如果一个国家一年内没有数据,那么数据就是不平衡的。理想情况下,您希望有一个平衡的数据集,但这并不总是但是,您仍然可以运行模型。 注意事项:如果在使用xtset后出现以下错误: varlist: country: string variable not allowed 解决方案为: encode country, gen(country1) 在xtset命令中使用“country1”而不是“country” 需要使用数值型类型
结果为: 如果放在一张图里面,操作为 xtline y, overlay 结果为:
xi: regress y x1 i.country
xtreg y x1, fe 注意和下面对比系数
固定效应结果统计量解释 其中: 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如果这个数字< 0.05,那么您的模型就可以了。这是一个检验(F),看看模型中的所有系数是否都不为零。 corr(u_i, Xb) = -0.5468 表示ui与解释变量的相关性 t值检验各系数为不同于0的假设 。要拒绝它,t值必须高于1.96(95%可信)。如果这在这种情况下,你可以说变量对因变量有显著影响,t值越高,变量的相关性越高。 双尾p值测试:假设每个系数不等于0。为了拒绝这个,p值需要小于0.05 (95%) areg y x1, absorb(country) 结果为:
结果为: 对比上述固定效应操作结果 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) 结果为: 随机操作操作
结果为: 随机操作操作 xtreg y x1, fe estimates store fixed xtreg y x1, re estimates store random hausman fixed random 结果为: 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 。
结果为: Testing for random effects: Breusch-Pagan Lagrange multiplier (LM) xtreg y x1, re xttest0 横断面相关性/同期相关性检验:
异方差检验检验: ssc install xtest3 xttest3 序列相关检验 系列相关测试适用于的长面板数据(20-30年以上)。
|
|