全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
30199 22
2011-03-20
我想用difference in differences 做一个回归:
要回归一下 p对y的影响 x1,x2,x3是其他影响y的变量 p是虚拟变量
恳请哪位给编写下命令 还有海需要什么检验之类的吗 谢谢哦
二维码

扫码加我 拉你入群

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

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

全部回复
2011-3-20 20:17:17
just findit  diff in stata, you will get what you want.
二维码

扫码加我 拉你入群

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

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

2011-3-21 12:15:00
所谓DID没有楼上说的diff这种荒谬的命令。
他是估计一个交叉项,比如,你方程中有一个政策dummy,一个时间dummy, 然后在把这两个dummy交叉相乘放入回归方程中,交叉项的系数就是放映了DID政策效果的真实原因。
二维码

扫码加我 拉你入群

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

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

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.
二维码

扫码加我 拉你入群

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

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

2011-3-22 13:52:02
4# sstxwx

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

扫码加我 拉你入群

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

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

2011-3-22 19:02:29
顶     好东西!!!!!!!!!!
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群