【问题标题】:Plot the marginal effect of different regressions in one graph在一张图中绘制不同回归的边际效应
【发布时间】:2020-03-05 15:34:42
【问题描述】:

我在不同的数据集上运行相同的 probit 回归五次。

如何在同一张图上绘制每个回归的边际效应曲线,以便轻松比较它们?

下面是我试过的代码:

probit one_y_unemp year* MR* AG* if Qualifica2 == 1
margins, dydx(year*) saving(me_intern, replace)

probit one_y_unemp year* MR* AG* if Qualifica3 == 1
margins, dydx(year*) saving(me_seniormanager, replace)

probit one_y_unemp year* MR* AG* if Qualifica4 == 1
margins, dydx(year*) saving(me_whitecollar, replace)

probit one_y_unemp year* MR* AG* if Qualifica5 == 1
margins, dydx(year*) saving(me_bluecollar, replace)

probit one_y_unemp year* MR* AG* if Qualifica6 == 1
margins, dydx(year*) saving(me_juniormanager, replace)

combomarginsplot me_intern me_seniormanager me_whitecollar me_bluecollar me_juniormanager, ///
labels("Intern" "Manager" "White Collar" "Blue Collar" "Junior Manager") xtitle("Years")

我对这段代码的问题是,我获得的图表不是每个专业角色都有一条曲线,并且 x 轴上有年份虚拟变量,而是每个虚拟年份有一条线。

【问题讨论】:

    标签: graph regression stata marginal-effects


    【解决方案1】:

    您可以使用 community-contributed 命令 coefplot 代替:

    sysuse auto, clear
    estimates clear
    
    egen price2 = std(price)
    egen rep782 = std(rep78)
    replace rep782 = rep78 * -10
    
    regress mpg i.foreign##c.price2 rep78
    margins, dydx(foreign) at(price2=(-3(0.5)3)) post
    estimates store m1
    
    regress mpg i.foreign##c.rep782 price2
    margins, dydx(foreign) at(rep782=(-3(0.5)3)) post
    estimates store m2
    
    coefplot m1 m2, at
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-13
      • 2021-07-18
      • 2019-08-05
      • 2019-11-16
      • 2019-07-15
      • 2020-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多