楼主: quanshui126
28712 22

[回归分析求助] 关于倍差法 difference in differences 一些命令 [推广有奖]

  • 0关注
  • 1粉丝

硕士生

39%

还不是VIP/贵宾

-

威望
0
论坛币
96 个
通用积分
0.0001
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1314 点
帖子
149
精华
0
在线时间
114 小时
注册时间
2009-7-28
最后登录
2016-5-31

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我想用difference in differences 做一个回归:
要回归一下 p对y的影响 x1,x2,x3是其他影响y的变量 p是虚拟变量
恳请哪位给编写下命令 还有海需要什么检验之类的吗 谢谢哦
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:differences difference DIFFER erence Diff difference 影响

沙发
nkzzq5566 发表于 2011-3-20 20:17:17 |只看作者 |坛友微信交流群
just findit  diff in stata, you will get what you want.
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 100 + 8 + 1 + 1 + 1 热心帮助其他会员

总评分: 经验 + 100  论坛币 + 8  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

藤椅
jannsz06 发表于 2011-3-21 12:15:00 |只看作者 |坛友微信交流群
所谓DID没有楼上说的diff这种荒谬的命令。
他是估计一个交叉项,比如,你方程中有一个政策dummy,一个时间dummy, 然后在把这两个dummy交叉相乘放入回归方程中,交叉项的系数就是放映了DID政策效果的真实原因。

使用道具

板凳
sstxwx 发表于 2011-3-22 11:14:33 |只看作者 |坛友微信交流群
help diff
-------------------------------------------------------------------------------

Title

    diff --       Differences in differences estimation


Syntax

        diff outcome_var [if] [in] [weight] ,[ options]


Description

    diff performs several differences in differences (diff-in-diff)
    estimations of the treatment effect of a given outcome variable from a
    pooled base line and follow up dataset: Single Diff-in-Diff, Diff-in-Diff
    controlling for covariates, Kernel-based Propensity Score Matching
    diff-in-diff, and the Quantile Diff-in-Diff.


Options

    options               description
    -------------------------------------------------------------------------
    Model - Required
      period(varname)     Indicates the dummy period variable (0: base line;
                            1: follow up).
      treated(varname)    Indicates the dummy treated variable (0: controls;
                            1:treated).

    Optional
      cov(varlist)        Specifies the pre-treatment covariates of the
                            model. When option kernel is selected these
                            variables are used to generate the propensity
                            score.
      kernel              Performs the Kernel-based Propensity Score Matching
                            diff-in-diff. This option generates _weights that
                            contains the weights derived from the kernel
                            density function, _ps when the Propensity Score
                            is not specified and _wght_varname with the
                            weighted outcome variable. This option requires
                            the id(varname) of each individual.
      id(varname)         Option kernel requires the supply of the
                            identification variable.
      bw(#)               Supplied bandwidth of the kernel. The default is
                            the optimum bw estimated by Stata. See [R]
                            kdensity
      ktype(kernel)       Specifies the kernel function; the default is
                            epanechnikov.  See [R] kdensity
      qdid(quantile)      Performs the Quantile Difference in Differences
                            estimation at the specified quantile from 0.1 to
                            0.9 (quantile 0.5 performs the QDID at the
                            medeian). You may combine this option with kernel
                            and cov options. qdid does not support weights
                            nor robust standard errors.  This option uses [R]
                            qreg and [R] bsqreg for bootstrapped standard
                            errors
      pscore(varname)     Supplied Propensity Score.
      logit               Specifies logit estimation of the Propensity Score.
                            The default is Probit.

    SE/Robust
      cluster(varname)    Calculates clustered Std. Errors by varname.
      robust              Calculates robust Std. Errors.
      bs                  performs a Bootstrap estimation of coefficients and
                            standard errors.
      reps(int)           Specifies the number of repetitions when the bs is
                            selected. The default are 50 repetitions.

    Balancing test
      test                Performs a balancing t-test of difference in means
                            of the specified covariates between control and
                            treated groups in period == 0. The option test
                            combined with kernel performs the balancing
                            t-test with the weighted covariates.  See [R]
                            ttest

    Reporting
      report              Displays the inference of the included covariates
                            or the estimation of the Propensity Score when
                            option kernel is specified.
      nostar              Removes the inference stars from the p-values.


    -------------------------------------------------------------------------


Example

    Install diff and/or check for updates.

         ssc inst diff, replace

    1. Diff-in-Diff with no covariates.
    We use the dataset form Card & Krueger (1994)*.

         net get diff

         use cardkrueger1994, clear

         diff fte, t(treated) p(t)

    For bootstrapped std. err.:

         diff fte, t(treated) p(t) bs rep(50)

    2. Diff-in-Diff with covariates.

         diff fte, t(treated) p(t) cov(bk kfc roys)
         diff fte, t(treated) p(t) cov(bk kfc roys) report
         diff fte, t(treated) p(t) cov(bk kfc roys) report bs

    3. Kernel Propensity Score Matching Diff-in-Diff.

         diff fte, t(treated) p(t) cov(bk kfc roys) kernel id(id)
         diff fte, t(treated) p(t) report kernel id(id) ktype(gaussian) pscore(
> _ps)
         diff fte, t(treated) p(t) bs kernel id(id) bw(0.006) pscore(_ps)

    4. Quantile Diff-in-Diff.

         diff fte, t(treated) p(t) qdid(0.25)
         diff fte, t(treated) p(t) qdid(0.50)
         diff fte, t(treated) p(t) qdid(0.75)
         diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys)
         diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys) kernel id(id)
         diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys) kernel id(id) bs
>  reps(100)

    5. Balancing test of covariates.

         diff fte, t(treated) p(t) cov(bk kfc roys wendys) test
         diff fte, t(treated) p(t) cov(bk kfc roys wendys) test id(id) kernel

Saved results

    diff saves the following list of scalars in r():

      r(mean_c0)      mean of output_var of the control group in period t=0
      r(mean_t0)      mean of output_var of the treated group in period t=0
      r(diff0)        difference of the mean of output_var between treated
                       and control groups in period t=0
      r(mean_c1)      mean of output_var of the control group in period t=1
      r(mean_t1)      mean of output_var of the treated group in period t=1
      r(diff1)        difference of the mean of output_var between treated
                       and control groups in period t=1
      r(diffdiff)     differences in differences - Treatment Effect
      r(se_c0)        Standard Error of the mean of output_var of the control
                       group in period t=0
      r(se_t0)        Standard Error of the mean of output_var of the treated
                       group in period t=0
      r(se_d0)        Standard Error of the difference of output_var between
                       the treated and control groups in t=0
      r(se_c1)        Standard Error of the mean of output_var of the control
                       group in period t=1
      r(se_t1)        Standard Error of the mean of output_var of the treated
                       group in period t=1
      r(se_d1)        Standard Error of the difference of output_var between
                       the treated and control groups in t=0
      r(se_dd)        Standard Error of the difference in difference

References

    Card, D., Krueger, A. "Minimum Wages and Employment: A Case Study of the
        Fast-Food Industry in New Jersey and Pennsylvania".  The American
        Economic Review, Vol. 84, No. 4 (Sep., 1994), pp. 772-793.

    Heckman, J., Ichimura, H., Todd, P. "Matching As an Econometric
        Evaluation Estimator". The Review of Economic Studies, Vol. 65, No. 2
        (Apr., 1998), pp. 261-294.

    Meyer, B., Viscusi, W., . "Workers' Compensation and Injury Duration:
        Evidence from a Natural Experiment". The American Economic Review,
        Vol. 85, No.3 (Jun., 1995), pp. 322-340.

Author

    Juan M. Villa
    Office of Strategic Planning and Development Effectiveness
    Inter-American Development Bank (not responsible)
    juanmiguelv@iadb.org

    Update: November - 2010
    *Acknowledgements to Kit Baum for valuable comments.
已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
zhangyubaobao + 1 + 1 + 1 精彩帖子
Sunknownay + 100 + 8 + 1 + 1 + 1 热心帮助其他会员

总评分: 经验 + 100  论坛币 + 8  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

使用道具

报纸
jannsz06 发表于 2011-3-22 13:52:02 |只看作者 |坛友微信交流群
4# sstxwx

这个没有仔细研究,不过能够结合PSM方法,应该比我说的传统的DID更加先进。不过我看的AER上的犯罪(Magan law对房产价格影响 1998的论文)是我说的那种做法。既然heckman一做了这种研究,我猜测是选择性偏误(样本不随机)的处理。这个命令值得研究哈,后面的3篇参考文献很重要。

使用道具

地板
gdczlhd 发表于 2011-3-22 19:02:29 |只看作者 |坛友微信交流群
顶     好东西!!!!!!!!!!
寻梦?撑一支长篙,向青草更青处漫溯;满载一船星辉,在星辉斑斓里放歌。

使用道具

7
quanshui126 发表于 2011-3-22 19:57:28 |只看作者 |坛友微信交流群
可是,具体的操作命令是什么呢

使用道具

8
amwwyof 发表于 2012-3-6 19:47:39 |只看作者 |坛友微信交流群
不错,下了。谢了

使用道具

9
errorpig 发表于 2012-3-14 23:14:28 |只看作者 |坛友微信交流群
嗯 有收获

使用道具

10
wldx1010 发表于 2012-5-9 12:13:41 |只看作者 |坛友微信交流群
学习啦

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-4 14:09