Announcement

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

  • Compare coefficients after reg3

    This might be something simple, but I cannot wrap my head around it. I am trying to compare coefficients from two regressions that use subsamples after reg3 by storing them but I cannot figure out how to refer to the coefficients in the code to call them back and compare. Here is a simplified example. Note: in the actual problem, I am using panel data, so I cannot do an interaction as my dummy variable is endogenous.
    Code:
    sysuse auto
    bootstrap, reps(100):reg3 ( price mpg) ( weight length)
    estimates store eq1
    bootstrap, reps(100):reg3 ( price mpg) ( weight length) if foreign==1
    estimates store eq1
    I want to compare stored mpg coefficient in eq1 and mpg coefficient in equation eq2 by using "test". Something like test [eq1_mean]mpg=[eq2_mean]mpg

    suest reports that it does not work with reg3.

    Thanks
    Last edited by Kelvin Hici; 14 Aug 2020, 06:06.

  • #2
    The meaning of the word "compare" in this context is not defined. You want to eyeball the coefficients? Or you want to do hypothesis testing?

    Also you are assigning two equations to the same name, so this would not work.

    If you just want to eyeball them, here:

    Code:
    . 
    . estimates store eq2
    
    . esttab eq1 eq2
    
    --------------------------------------------
                          (1)             (2)   
                        price           price   
    --------------------------------------------
    price                                       
    mpg                -205.3***       -225.6** 
                      (-4.14)         (-3.02)   
    
    _cons             10536.8***      11973.8***
                       (8.45)          (6.03)   
    --------------------------------------------
    weight                                      
    length              32.50***        26.90***
                      (26.83)          (7.31)   
    
    _cons             -3088.1***      -2217.8***
                     (-13.13)         (-3.63)   
    --------------------------------------------
    N                      74              22   
    --------------------------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    
    .

    Comment


    • #3
      This should extract you the coefficients.

      sysuse auto
      bootstrap, reps(100):reg3 ( price mpg) ( weight length)
      gen pricempgCf = [price]_b[mpg]
      gen weightlengthCf = [weight]_b[length]
      bootstrap, reps(100):reg3 ( price mpg) ( weight length) if foreign==1
      gen pricempgCfwithForeign1 = [price]_b[mpg]
      gen weightlengthCfwithForeign1 = [weight]_b[length]

      Comment


      • #4
        Joro Kolev I see I edited the comment when you had already replied. I am trying to do a hypothesis test of the equality of the coefficients in the two regressions using test. The other one should be eq2. It was an error.

        Oscar Ozfidan retrieving the coefficients in this manner does not seem to allow me to do a hypothesis test. It just saved the coefficient as a single value. Any help that would allow me to do a hypothesis test?

        Comment


        • #5
          That I dont know
          Last edited by Oscar Ozfidan; 14 Aug 2020, 13:14.

          Comment


          • #6
            I am supposed to know how to do this, and I have done it many times, and this below is supposed to work... But it is not working, and I cannot see why it is not working :-( .

            Code:
            sysuse auto, clear
            
            cap prog drop myboot
            
            prog define myboot, rclass
            
            reg3 ( price mpg) ( weight length)
            
            sca Pricempg = [price]mpg
            
            reg3 ( price mpg) ( weight length) if foreign==1
            
            return sca Diff = Pricempg - [price]mpg
            
            end
            
            bootstrap Diff=r(Diff), reps(100) : myboot
            Stata return this, meaning that my statistic Diff is identically 0 in all bootstrap samples.

            Code:
            . bootstrap Diff=r(Diff), reps(100) : myboot
            (running myboot on estimation sample)
            
            Bootstrap replications (100)
            ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
            ..................................................    50
            ..................................................   100
            
            Bootstrap results                               Number of obs     =         22
                                                            Replications      =        100
            
                  command:  myboot
                     Diff:  r(Diff)
            
            ------------------------------------------------------------------------------
                         |   Observed   Bootstrap                         Normal-based
                         |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                    Diff |   20.35371          .        .       .            .           .
            ------------------------------------------------------------------------------
            
            .

            Comment

            Working...
            X