Announcement

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

  • 2SLS, Instrument Variable

    Hey I want to ask if I am applying 2sls in 2 stages, do I have to have covariates in both stages or in just 2nd stage? Also if I have to add covariates in both stages, then is it a compulsion to use same covariates in both or can use 1 or 2 different covariates?

  • #2
    In two-stage least squares (2SLS), the exogenous variables must appear in both stages. In the first stage, you regress the endogenous variable \(X\) on the instruments \(Z\) and all exogenous covariates \(W\):

    \[
    X = \pi_{0} + Z\pi_{1} + W\pi_{2} + u
    \]

    This gives you \(\hat{X}\), the predicted values of \(X\) that are purged of the endogeneity problem. In the second stage, you regress the dependent variable \(Y\) on \(\hat{X}\) and the same \(W\):

    \[
    Y = \beta_{0} + \beta_{1} \hat{X} + W\beta_{2} + \varepsilon
    \]

    If you omit the exogenous variables from the first stage but keep them in the second, your \(\hat{X}\) will not be the correct projection of \(X\) on the instrument set conditional on \(W\). This mismatch means \(\hat{X}\) may still be correlated with the error term in the second stage, leading to inconsistency. Here is an example:

    Code:
    webuse hsng2, clear
    *IV2SLS
    ivregress 2sls rent pcturban (hsngval = faminc i.region), vce(bootstrap, seed(07212025))
    
    *IN TWO STEPS
    cap prog drop mybootstrap_prog
    prog mybootstrap_prog
    regress hsngval faminc i.region pcturban
    predict hsngvalhat, xb
    regress rent hsngvalhat pcturban
    drop hsngvalhat
    end
    bootstrap _b , reps(50) nowarn nodots nodrop seed(07212025): mybootstrap_prog

    Res.:

    Code:
    . *IV2SLS
    
    .
    . ivregress 2sls rent pcturban (hsngval = faminc i.region), vce(bootstrap, seed(07212025))
    (running ivregress on estimation sample)
    
    Bootstrap replications (50): .........10.........20.........30.........40.........50 done
    
    Instrumental-variables 2SLS regression            Number of obs   =         50
                                                      Wald chi2(2)    =      36.58
                                                      Prob > chi2     =     0.0000
                                                      R-squared       =     0.5989
                                                      Root MSE        =     22.166
    
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                         Normal-based
            rent | coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0022398   .0005969     3.75   0.000     .0010699    .0034098
        pcturban |    .081516    .437207     0.19   0.852    -.7753941     .938426
           _cons |   120.7065   17.98488     6.71   0.000      85.4568    155.9562
    ------------------------------------------------------------------------------
    Endogenous: hsngval
    Exogenous:  pcturban faminc 2.region 3.region 4.region
    
    .
    .
    .
    . *IN TWO STEPS
    
    .
    . cap prog drop mybootstrap_prog
    
    .
    . prog mybootstrap_prog
      1.
    . regress hsngval faminc i.region pcturban
      2.
    . predict hsngvalhat, xb
      3.
    . regress rent hsngvalhat pcturban
      4.
    . drop hsngvalhat
      5.
    . end
    
    .
    . bootstrap _b , reps(50) nowarn nodots nodrop seed(07212025): mybootstrap_prog
    
    Linear regression                                      Number of obs =      50
                                                           Replications  =      50
                                                           Wald chi2(2)  =   36.58
                                                           Prob > chi2   =  0.0000
                                                           R-squared     =  0.7281
                                                           Adj R-squared =  0.7166
                                                           Root MSE      = 18.8218
    
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                         Normal-based
            rent | coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
      hsngvalhat |   .0022398   .0005969     3.75   0.000     .0010699    .0034098
        pcturban |   .0815159    .437207     0.19   0.852    -.7753941     .938426
           _cons |   120.7065   17.98488     6.71   0.000      85.4568    155.9562
    ------------------------------------------------------------------------------
    
    .

    Comment

    Working...
    X