panel data 应用实例 stata code-2 (Fixed Effect-LSDV)

标签:
面板数据fixedlsdv例子stata |
分类: SAS_STATA_GAMS_MATLAB_Hadoop |
这一节用Fixed group effects.
假设每个group(航线)有相同的截距,不同的航线有不同的截距。这也就是上一篇博客最后的第一个疑问。
其中一种常用的方法是LSDV, 即 Least Square with Dummy Variables。
还是用的上一节的data:
第一步是建立Dummy
Variable。
gen g1=(airline==1)
gen g2=(airline==2)
gen g3=(airline==3)
gen g4=(airline==4)
gen g5=(airline==5)
gen g6=(airline==6)
新生成的数据如下图所示:
http://s8/mw690/002dDHI1gy6JTj5uhvh17&690data 应用实例 stata code-2 (Fixed Effect-LSDV)" TITLE="panel data 应用实例 stata code-2 (Fixed Effect-LSDV)" />
LSDV model为:
http://s11/mw690/002dDHI1gy6JTjbsFt05a&690data 应用实例 stata code-2 (Fixed Effect-LSDV)" TITLE="panel data 应用实例 stata code-2 (Fixed Effect-LSDV)" />
stata code 为:
stata code 为:
regress cost g1-g5 output fuel
load
结果如下:
http://s3/mw690/002dDHI1gy6JTjfWZ0K22&690data 应用实例 stata code-2 (Fixed Effect-LSDV)" TITLE="panel data 应用实例 stata code-2 (Fixed Effect-LSDV)" />
This LSDV fits the data better than does the pooled OLS in the previous example. 在上一例中,F值为2419, 这个例子中为3935. SSE 在上一例中为1.34, 而这里仅为0.29. R square 同样在这个model中增加。
This LSDV fits the data better than does the pooled OLS in the previous example. 在上一例中,F值为2419, 这个例子中为3935. SSE 在上一例中为1.34, 而这里仅为0.29. R square 同样在这个model中增加。
在这个model中,每个航线有自己的intercept(截距),即初始cost (initial cost),
相同的斜率。
因为我们只能选择五个airlines在模型里,g6的截距为9.79....
航线1的截距为-0.087+9.79=9.7
此外,如果不想手动生成dummy variable的话,可以用下面这个命令自动生成dummy:
xi: regress cost i.airline output fuel
load
结果和上面一样。
此外,在这个例子里,我们用了五个airlines,drop了一个,也可以选所有的airlines,但不生成截距。drop一组的方法一般称为LSDV1.
不生成截距的方法一般称为LSDV2.
regress cost g1-g6 output fuel load,
noconstant
斜率结果是一样的,但F值和R-square可能不准确。
此外还有LSDV3. 在这里不展开讨论。其中,LSDV1是最常用的方法。
注: 我并不是原创,不过是根据读书笔记整理出来的,稍后会把相关的reference整理出来。