美文网首页stata stata连享会计量经济学(stata)
Stata:图示连续变量的边际效应(交乘项)

Stata:图示连续变量的边际效应(交乘项)

作者: stata连享会 | 来源:发表于2018-04-20 15:41 被阅读400次

    作者:连玉君 (知乎 | 简书 | 码云)

       …… Stata连享会 - 往期精彩推文 ……

    Stata 现场培训报名中

    背景

    交乘项的使用越来与普遍。Stata 官方提供的 margins 以及 marginsplot 命令可以很好地分析和图示边际效果。其局限在于只能呈现特定数值上的边际效应,而无法连续的呈现边际效应。

    外部命令 interflex 可能弥补这一局限。

    这里介绍的 marginscontplot2 也可以很好地实现这一分析目的。

    命令解释和帮助文件

    marginscontplot2 provides a graph of the marginal effect of a continuous predictor on the response variable in the most recently fitted regression model. See Royston (2013) for details and examples; the paper is available at http://www.stata-journal.com/article.html?article=gr0056.

    • help marginscontplot2 // Graph margins for continuous predictors

    Examples

    *-Basic examples
      sysuse auto, clear
      regress mpg i.foreign weight
      marginscontplot2 weight, name(my_graph)
      marginscontplot2 weight, at1(2000(100)4500) ci
      marginscontplot2 weight foreign, var1(20) at2(0 1)
      marginscontplot2 weight foreign, var1(20) at2(0 1) ///
          ci combopts(ycommon imargin(small))
     
    *-Example using a log-transformed covariate
      gen logwt = log(weight)
      regress mpg i.foreign c.logwt i.foreign#c.logwt
      quietly summarize weight
      range w1 r(min) r(max) 20
      generate logw1 = log(w1)
      marginscontplot2 weight (logwt), var1(w1 (logw1)) ci
    

    输出效果:


    marginscontplot2 - 输出效果.png

    References

    • Royston, P. 2013. marginscontplot2: Plotting the marginal effects of continuous predictors. Stata Journal, 13(3): 510-527.

    关于我们

    联系我们

    • 欢迎赐稿: 欢迎将您的文章或笔记投稿至Stata连享会(公众号: StataChina),我们会保留您的署名;录用稿件达五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。
    • 意见和资料: 欢迎您的宝贵意见,您也可以来信索取推文中提及的程序和数据。
    • 招募英才: 欢迎加入我们的团队,一起学习 Stata。合作编辑或撰写稿件五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。
    • 联系邮件: StataChina@163.com

    往期精彩推文

    Stata连享会推文列表

    Stata 现场培训报名中

    连玉君Stata现场班报名中

    欢迎加入Stata连享会(公众号: StataChina)

    相关文章

      网友评论

        本文标题:Stata:图示连续变量的边际效应(交乘项)

        本文链接:https://www.haomeiwen.com/subject/vetzkftx.html