我的模型有不同的因变量(DVs),但使用相同的工具变量(IV),有两种不同类型的识别策略。简言之,我有:
Group1
model 1
model 2
model 3
model 4
Group2
model 1-2
model 2-2
model 3-2
model 4-2
我想绘制出可以比较模型1和模型1-2,模型2和模型2-2的IV的系数估计值的系数。马上就来。我想在一个图表中画出八个系数,因为所有模型的兴趣IV都是相同的。
有没有一种程式化的方法来做到这一点?
目前,我只知道如何在一个图中绘制模型1和模型1-2的协同图,而不是所有其他图。我希望根据模型编号(1,2,3,4)水平绘制系数,并比较模型1和模型1-2的系数;模型2和模型2-2,对“x-轴”上的每个模型数进行比较。
发布于 2019-01-31 13:32:09
社区提供的命令coefplot
不应该像那样使用。
尽管如此,下面是一个玩具示例,说明如何获得所需的东西:
sysuse auto, clear
estimates clear
// code for identification strategy 1
regress price mpg trunk length turn if foreign == 0
estimates store A
regress price trunk turn if foreign == 0
estimates store B
regress price weight trunk turn if foreign == 0
estimates store C
regress price trunk if foreign == 0
estimates store D
// code for identification strategy 2
regress price mpg trunk length turn if foreign == 1
estimates store E
regress price trunk turn if foreign == 1
estimates store F
regress price weight trunk turn if foreign == 1
estimates store G
regress price trunk if foreign == 1
estimates store H
然后,你画的情节如下:
local gap1 : display _dup(30) " "
local gap2 : display _dup(400) " "
local label1 |`gap1'|`gap1'|`gap1'|`gap2'
local gap3 : display _dup(25) " "
local gap4 : display _dup(400) " "
local label2 DV1`gap3'DV2`gap3'DV3`gap3'DV4`gap4'
coefplot (A, offset(-0.38)) (E, offset(-0.33)) ///
(B, offset(-0.15)) (F, offset(-0.1)) ///
(C, offset(0.09)) (G, offset(0.135)) ///
(D, offset(0.3)) (H, offset(0.35)), ///
vertical keep(trunk) coeflabels(trunk = `""`label1'""`label2'""') ///
xlabel(, notick labgap(0)) legend(off)
这里的代码使用Stata的玩具auto
数据集为每个foreign
类别运行许多简单的回归。使用相同的因变量price
作为示例,但您可以在其位置使用不同的变量。这里假定变量trunk
是感兴趣的变量。
上面的玩具代码片段基本上是保存每组回归估计,然后模拟成对的模型。标签DV
是基于我最近在以下两个问题中演示的一个黑客绘制的:
其结果是一个非常好的近似,但需要您的部分进行实验:
https://stackoverflow.com/questions/54452556
复制相似问题