Announcement

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

  • testing coefficients after rifreg with bootstrap s.e.

    Dear all,

    I use user written command rifreg (Rios-Avila, F. 2020. Recentered influence functions (RIFs) in Stata: RIF regression and RIF decomposition. Stata Journal, 20(1), 51-94. https://doi.org/10.1177/1536867X20909690.)

    I estimate two regressions, separately by gender, and I want to test if coefficients are equal for explanatory variables between males and females. Since I use bootstrap standard errors, I had to write a program. The problem that arise is that standard errors for t test are different then standard errors in regresion.

    Here is code for example dataset.

    use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta, clear


    program dob,eclass
    rifreg lnwage educ exper tenure if female==1, q(10)
    matrix bf10=_b[educ]
    rifreg lnwage educ exper tenure if female==0, q(10)
    matrix bm10=_b[educ]
    matrix b= bf10, bm10
    matrix colname b = bf10 bm10
    ereturn post b
    end


    bootstrap, seed(1): dob if lnwage!=. & educ!=. & exper!=. & tenure!=.
    test _b[bf10]==_b[bm10]

    bootstrap, seed(1): rifreg lnwage educ exper tenure if female==1, q(10)
    bootstrap, seed(1): rifreg lnwage educ exper tenure if female==0, q(10)


    Here are the results, I marked standard errors for education that differ.


    Bootstrap results Number of obs = 1,434
    Replications = 50

    ------------------------------------------------------------------------------
    | Observed Bootstrap Normal-based
    | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    bf10 | .0714448 .0322978 2.21 0.027 .0081423 .1347473
    bm10 | .0757839 .0153426 4.94 0.000 .0457131 .1058547
    ------------------------------------------------------------------------------

    . test _b[bf10]==_b[bm10]

    ( 1) bf10 - bm10 = 0

    chi2( 1) = 0.01
    Prob > chi2 = 0.9036


    (1) (2)
    VARIABLES f 10 m 20
    educ 0.0714** 0.0758***
    (0.0335) (0.0126)
    exper 0.0172* 0.0169***
    (0.0092) (0.0035)
    tenure -0.0037 0.0039
    (0.0074) (0.0038)
    Constant 1.7770*** 1.8451***
    (0.5167) (0.1969)
    Observations 683 751
    R-squared 0.0427 0.1221
    Standard errors in parentheses
    *** p<0.01, ** p<0.05, * p<0.1
    Thank you very much in advance.

    Best,
    Aleksandra



  • #2
    Hi Aleksandra,
    The problem that you see is not unique to RIF regressions, but rather to the use of Bootstrap Standard errors.
    1. As you may know, bootstrap is a method to estimate standard error that relies on random draws from your sample. So, different samples will provide different draws, and different standard errors.
    2. Since you are using Seed, you can replicate the bootstrap results every time you use the test. However, when you run the models separately, the sample within model is different from the whole, Thus the standard errors will be different. They may coverage to each other asymptotically (using thousands or hundred of thousands of repetitions), but will never be exactly the same (unless all possible bootstrap samples are used).
    3. I think the best option for you would be to modify your program so it gives you BOTH male and female regression outputs simultaneously:

    Code:
    program drop dob
    program dob,eclass
    rifreg lnwage educ exper tenure if female==1, q(10)
    matrix bf10=e(b)
    rifreg lnwage educ exper tenure if female==0, q(10)
    matrix bm10=e(b)
    matrix coleq bf10  = bf10 
    matrix coleq bm10 = bm10
    matrix b= bf10, bm10
     ereturn post b
    end
    
    bootstrap, seed(1): dob if lnwage!=. & educ!=. & exper!=. & tenure!=.
    
    Bootstrap replications (50)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
    ..................................................    50
    
    Bootstrap results                                        Number of obs = 1,434
                                                             Replications  =    50
    
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                         Normal-based
                 | coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    bf10         |
            educ |   .0714448   .0322978     2.21   0.027     .0081423    .1347473
           exper |   .0172491   .0092122     1.87   0.061    -.0008066    .0353047
          tenure |  -.0036893   .0069779    -0.53   0.597    -.0173656    .0099871
           _cons |   1.777048   .4725104     3.76   0.000     .8509448    2.703151
    -------------+----------------------------------------------------------------
    bm10         |
            educ |   .0757839   .0153426     4.94   0.000     .0457131    .1058547
           exper |   .0169089   .0033948     4.98   0.000     .0102552    .0235626
          tenure |   .0038669   .0034169     1.13   0.258    -.0028301    .0105639
           _cons |   1.845055   .2369992     7.79   0.000     1.380545    2.309565
    ------------------------------------------------------------------------------
    So with that, you can still apply "test" as you did before.

    HTH

    Comment

    Working...
    X