Announcement

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

  • Compare estiamtes of full and subsample after ivreg

    Dear Statalist community,

    I am trying to compare the estimates of an IV regression of the full sample vs. the subsample. I found some examples (https://www.stata.com/statalist/arch.../msg00487.html, https://www.stata.com/statalist/arch.../msg00373.html) but have problems adjusting them to my context.

    What I have is the following:

    Code:
    global X x1 x2 x3 x4 x5
    
    *full sample
    xtivreg2 Y $X (x_endo = z), fe first endog(x_endo)
    est store FS1
    
    *subsample
    xtivreg2 Y $X (x_endo = z) if gender==1, fe first endog(x_endo)
    est store SS1
    Now I would like to statistically compare the estimates of x_endo and x1 in both regressions.

    Trying the following produced an error:

    Code:
    testnl [FS1_Y]x_endo=[SS1_]x_endo
    equation [FS1_Consumption] not found
    r(303);

    What can I do instead?

    Thanks!

  • #2
    Tests over overlapping samples can be difficult to interpret. It's akin to claiming that London's GDP per capita is higher than Britain's, despite London being part of Britain. Nevertheless, you can duplicate the data and proceed in the same way as you would with disjoint samples. See https://www.statalist.org/forums/for...ferent-samples.
    Last edited by Andrew Musau; 18 Sep 2023, 17:01.

    Comment


    • #3
      Hey Andrew,

      Thank you for your answer.

      As I am using a Fixed Effects estimation and my gender variable is time-invariant, it is dropped from the model. Therefore, it seems best to run two separate regressions:

      Code:
      xtivreg2 Y x1  $x (x_endo = Z) if gender==1, fe cluster(hhid) first
      est sto W1
      
      xtivreg2 Y x1  $x (x_endo = Z) if gender==0, fe cluster(hhid) first
      est sto W0
      
      test [W1_Y]x_endo=[W0_Y]x_endo
      Results in: equation [W1_Y] not found
      r(303);

      What can I do here?
      Last edited by Kerstin Schmidt; 19 Sep 2023, 09:33.

      Comment


      • #4
        Translating the example in https://www.statalist.org/forums/for...ferent-samples to your setting is as simple as:

        Code:
        webuse hsng2, clear
        *create subsample
        gen subsample= _n<26
        
        *FULL SAMPLE
        ivregress 2sls rent pcturban (hsngval = faminc i.region), robust
        *SUBSAMPLE
        ivregress 2sls rent pcturban (hsngval = faminc i.region) if subsample, robust
        
        
        *JOINT REGRESSION (interact variables with group variable). Note with 2 constant terms, we create our own
        expand 2 if subsample, gen(sub)
        
        lab def `:val lab sub' 0 "Full sample" 1 "Subsample", modify
        
        gen cons=1
        ivregress 2sls rent c.pcturban#i.sub c.cons#i.sub (c.hsngval#i.sub = (c.faminc i.region)#i.sub), nocons robust
        
        *Now compare coefficients across groups, e.g.,
        test 0.sub#c.hsngval=  1.sub#c.hsngval
        Res.:

        Code:
        . *FULL SAMPLE
        
        . 
        . ivregress 2sls rent pcturban (hsngval = faminc i.region), robust
        
        Instrumental variables (2SLS) regression          Number of obs   =         50
                                                          Wald chi2(2)    =      44.98
                                                          Prob > chi2     =     0.0000
                                                          R-squared       =     0.5989
                                                          Root MSE        =     22.166
        
        ------------------------------------------------------------------------------
                     |               Robust
                rent | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
             hsngval |   .0022398    .000672     3.33   0.001     .0009227    .0035569
            pcturban |    .081516   .4445938     0.18   0.855     -.789872    .9529039
               _cons |   120.7065   15.25546     7.91   0.000     90.80636    150.6067
        ------------------------------------------------------------------------------
        Instrumented:  hsngval
        Instruments:   pcturban faminc 2.region 3.region 4.region
        
        . 
        . *SUBSAMPLE
        
        . 
        . ivregress 2sls rent pcturban (hsngval = faminc i.region) if subsample, robust
        
        Instrumental variables (2SLS) regression          Number of obs   =         25
                                                          Wald chi2(2)    =      22.11
                                                          Prob > chi2     =     0.0000
                                                          R-squared       =     0.5444
                                                          Root MSE        =     27.437
        
        ------------------------------------------------------------------------------
                     |               Robust
                rent | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
             hsngval |   .0023382   .0009395     2.49   0.013     .0004968    .0041795
            pcturban |  -.3853024   .9975224    -0.39   0.699     -2.34041    1.569806
               _cons |   147.9727   34.01539     4.35   0.000     81.30382    214.6417
        ------------------------------------------------------------------------------
        Instrumented:  hsngval
        Instruments:   pcturban faminc 2.region 3.region 4.region
        
        . 
        . 
        . 
        . 
        . 
        . *JOINT REGRESSION (interact variables with group variable). Note with 2 constant terms, we create our own
        
        . 
        . expand 2 if subsample, gen(sub)
        (25 observations created)
        
        . 
        . 
        . 
        . lab def `:val lab sub' 0 "Full sample" 1 "Subsample", modify
        
        . 
        . 
        . 
        . gen cons=1
        
        . 
        . ivregress 2sls rent c.pcturban#i.sub c.cons#i.sub (c.hsngval#i.sub = (c.faminc i.region)#i.sub), nocons robust
        note: 4.region#1.sub omitted because of collinearity.
        
        Instrumental variables (2SLS) regression          Number of obs   =         75
                                                          Wald chi2(6)    =          .
                                                          Prob > chi2     =          .
                                                          R-squared       =          .
                                                          Root MSE        =     24.051
        
        --------------------------------------------------------------------------------
                       |               Robust
                  rent | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        ---------------+----------------------------------------------------------------
         sub#c.hsngval |
          Full sample  |   .0022398    .000672     3.33   0.001     .0009227    .0035569
            Subsample  |   .0023382   .0009395     2.49   0.013     .0004968    .0041795
                       |
        sub#c.pcturban |
          Full sample  |    .081516   .4445938     0.18   0.855     -.789872    .9529039
            Subsample  |  -.3853024   .9975224    -0.39   0.699     -2.34041    1.569806
                       |
            sub#c.cons |
          Full sample  |   120.7065   15.25546     7.91   0.000     90.80636    150.6067
            Subsample  |   147.9727   34.01539     4.35   0.000     81.30382    214.6417
        --------------------------------------------------------------------------------
        Instrumented:  0b.sub#c.hsngval 1.sub#c.hsngval
        Instruments:   0b.sub#c.pcturban 1.sub#c.pcturban 0b.sub#c.cons 1.sub#c.cons
                       0b.sub#c.faminc 1.sub#c.faminc 1b.region#1.sub 2.region#0b.sub
                       2.region#1.sub 3.region#0b.sub 3.region#1.sub 4.region#0b.sub
        
        . 
        . 
        . 
        . *Now compare coefficients across groups, e.g.,
        
        . 
        . test 0.sub#c.hsngval=  1.sub#c.hsngval
        
         ( 1)  0b.sub#c.hsngval - 1.sub#c.hsngval = 0
        
                   chi2(  1) =    0.01
                 Prob > chi2 =    0.9322
        Last edited by Andrew Musau; 19 Sep 2023, 09:46.

        Comment


        • #5
          Hey Andrew,

          I can fully replicate your example but applying it to a simplified model specification in my data shows a new error: "0b.subsample included in both exogenous and endogenous variable lists."

          Here is my code:
          Code:
          gen subsample = (gender==1)
          
          *JOINT REGRESSION (interact variables with group variable). Note with 2 constant terms, we create our own
          expand 2 if subsample, gen(sub)
          lab def `:val lab sub' 0 "Full sample" 1 "Subsample", modify
          
          gen cons=1
          
          ivregress 2sls Y i.x1##i.sub $x c.cons##i.sub (i.x_endo##i.sub = (c.Z##i.sub)), nocons robust
          What is wrong here?

          Comment


          • #6
            Without seeing your data and codes for the separate regressions, there is not much that I can comment on. The fixed effects add some extra complications, but there should be ways to handle them.

            Comment

            Working...
            X