Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Heterogeneous treatment effects with ivregress

    Dear Statalist,

    I want to calculate treatment heterogeneity in a two-stage-least-square (TSLS) setting. I have a continuous dependent variable y, a potentially endogenous predictor x (continuous), and an instrument z (continuous) that provides quasi-random variation in x.

    I use z to obtain a TSLS estimate (the local average treatment effect) for x. Now I want to calculate heterogeneous treatment effects for categories of w. In the specific case, w are three age categories, and I want to obtain TSLS estimates for the three age groups.

    (How) can I do this using the ivregress command?

    I considered estimating the effects separately in three different equations, i.e.

    Code:
    ivregress 2sls y (x = z) if w==1
    ivregress 2sls y (x = z) if w==2
    ivregress 2sls y (x = z) if w==3
    But is there also a way to specify this in a single model, for example

    Code:
    ivregress 2sls y (c.x#i.w = c.z#i.w)
    ?

    Your help is much appreciated.

    Max

  • #2
    Code:
    gen cons=1
    ivregress 2sls y (c.x#i.w = c.z#i.w) c.cons#i.w, nocons robust
    Example:

    Code:
    . webuse hsng2, clear
    (1980 Census housing data)
    
    . gen cons=1
    
    . bys region: ivregress 2sls rent (hsngval = faminc)
    
    ------------------------------------------------------------------------------------------------------------------------------------
    -> region = NE
    
    Instrumental variables (2SLS) regression          Number of obs   =          9
                                                      Wald chi2(1)    =      18.51
                                                      Prob > chi2     =     0.0000
                                                      R-squared       =     0.6410
                                                      Root MSE        =     11.056
    
    ------------------------------------------------------------------------------
            rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0019973   .0004642     4.30   0.000     .0010874    .0029071
           _cons |   144.5765   22.86467     6.32   0.000     99.76257    189.3904
    ------------------------------------------------------------------------------
    Instrumented:  hsngval
    Instruments:   faminc
    
    ------------------------------------------------------------------------------------------------------------------------------------
    -> region = N Cntrl
    
    Instrumental variables (2SLS) regression          Number of obs   =         12
                                                      Wald chi2(1)    =       5.97
                                                      Prob > chi2     =     0.0145
                                                      R-squared       =          .
                                                      Root MSE        =      22.87
    
    ------------------------------------------------------------------------------
            rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0044892   .0018372     2.44   0.015     .0008883    .0080901
           _cons |   31.19274   78.60508     0.40   0.691    -122.8704    185.2559
    ------------------------------------------------------------------------------
    Instrumented:  hsngval
    Instruments:   faminc
    
    ------------------------------------------------------------------------------------------------------------------------------------
    -> region = South
    
    Instrumental variables (2SLS) regression          Number of obs   =         16
                                                      Wald chi2(1)    =      50.30
                                                      Prob > chi2     =     0.0000
                                                      R-squared       =     0.7612
                                                      Root MSE        =     13.362
    
    ------------------------------------------------------------------------------
            rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0037331   .0005264     7.09   0.000     .0027015    .0047647
           _cons |   70.56917   20.91489     3.37   0.001     29.57673    111.5616
    ------------------------------------------------------------------------------
    Instrumented:  hsngval
    Instruments:   faminc
    
    ------------------------------------------------------------------------------------------------------------------------------------
    -> region = West
    
    Instrumental variables (2SLS) regression          Number of obs   =         13
                                                      Wald chi2(1)    =       7.91
                                                      Prob > chi2     =     0.0049
                                                      R-squared       =          .
                                                      Root MSE        =     49.405
    
    ------------------------------------------------------------------------------
            rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0035472   .0012613     2.81   0.005     .0010751    .0060192
           _cons |   31.82923   83.35954     0.38   0.703    -131.5525    195.2109
    ------------------------------------------------------------------------------
    Instrumented:  hsngval
    Instruments:   faminc
    Code:
    . ivregress 2sls rent (i.region#c.hsngval = i.region#c.faminc) c.cons#i.region, nocons robust
    
    Instrumental variables (2SLS) regression          Number of obs   =         50
                                                      Wald chi2(8)    =          .
                                                      Prob > chi2     =          .
                                                      R-squared       =          .
                                                      Root MSE        =      28.97
    
    ----------------------------------------------------------------------------------
                     |               Robust
                rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
    region#c.hsngval |
                 NE  |   .0019973   .0004092     4.88   0.000     .0011953    .0027993
            N Cntrl  |   .0044892   .0018388     2.44   0.015     .0008852    .0080933
              South  |   .0037331   .0007129     5.24   0.000     .0023358    .0051304
               West  |   .0035472   .0015312     2.32   0.021      .000546    .0065483
                     |
       region#c.cons |
                 NE  |   144.5765   18.35919     7.87   0.000     108.5932    180.5599
            N Cntrl  |   31.19274   74.60418     0.42   0.676    -115.0288    177.4143
              South  |   70.56917   26.07982     2.71   0.007     19.45367    121.6847
               West  |   31.82923   91.31469     0.35   0.727    -147.1443    210.8027
    ----------------------------------------------------------------------------------
    Instrumented:  1b.region#c.hsngval 2.region#c.hsngval 3.region#c.hsngval
                   4.region#c.hsngval
    Instruments:   1b.region#c.cons 2.region#c.cons 3.region#c.cons 4.region#c.cons
                   1b.region#c.faminc 2.region#c.faminc 3.region#c.faminc
                   4.region#c.faminc

    Comment


    • #3
      Excellent - thank you!

      Comment


      • #4
        A question comparing the answer to this post to the one at https://www.statalist.org/forums/for...eraction-terms.

        Both OP are trying to study heterogeneous treatment effects using TSLS but one answer suggests to run

        Code:
         ivregress 2sls y (c.x#i.w = c.z#i.w) c.cons#i.w, nocons robust
        while the other suggests something as

        Code:
         ivregress 2sls y (x c.x#i.w = z c.z#i.w) i.w, robust
        where not only the interaction but also the treatment and the instrument are included in the first stage on their own.

        Are the two procedures leading to the same result? Or is there something I am missing?

        Comment


        • #5
          I believe those are doing the same thing, but I prefer the second (partly because the output is easier to read). The second also makes it clear that w enters on its own with unrestricted coefficients across values and also interacts with x in an unrestricted way. We use the natural IVs for x and c.x#i.w. Probably centering x and z before interacting is a good idea for interpreting both the first and second stages.

          Comment


          • #6
            I am always struggling with IV so this is super helpful! Thanks Jeff!

            Comment

            Working...
            X