Announcement

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

  • Include computed standard error in user-written outreg2 Command

    Hi all,

    I have used the user-written command
    Code:
    boottest
    in order to generate a boostrapped CI. I've managed to save the upper and lower bounds of the bootstrapped 95% CI as scalars, and have used the following formula to generate a standard error: (upper bound + lower bound)/3.92

    Code:
            reghdfe y x i.Datum_n, abs(i.token1 ) vce(cluster canton) // user-written by Dr. Correia
               
        boottest x=0, seed(1234567890) reps(9999) weighttype(rademacher) bootcluster(canton) boottype(wild) nograph
    scalar ll = (r(CI)[1,1])
    matrix ul = (r(CI)[1,2])
    *ESTADD MATRICES // user-witten by Benn Jann I think
    estadd matrix myll= ll
    estadd matrix myul= ul
    scalar ll = (r(CI)[1,1])
    scalar ul = (r(CI)[1,2])
    g ll_sca=ll
    g ul_sca=ul
    
    g BS_se_coef_x= (ll+ul)/3.92
    However, I would now like to export the output using the user-written command outreg2, and I would like to use the newly computed standard error BS_se_coef_x as standard error below the coefficients posted in the outreg2 command.

    The normal outreg2 command I would write is the following:

    outreg2 using myfile.doc, replace keep(x) nocons addtext(Respondent FE, Yes, Month FE, Yes, Controls, No)

    Is there any way to replace the "CV1" cluster-robust standard error computed through the reghdfe model by BS_se_coef_x in the outreg2 output?

    Many thanks in advance!


    Code:
    input long token1 float Datum_n byte verpasstgrouptwosq001 float WFH
     100361664 730 5        1
     100361664 731 4        0
     100361664 744 5        0
     100361664 745 4        0
    1021535057 729 5        0
    1021535057 731 4        0
    1021535057 732 4        0
    1026478338 733 2        0
    1026478338 735 .        1
    1026478338 736 3        0
    1026478338 739 3        0
    1026478338 741 .        0
    1026478338 742 4        0
    1026478338 747 4        0
    1066614879 734 .        .
    1066614879 735 .        0
    1072513264 737 4        0
    1072513264 746 5        .
     111176343 744 5        0
     111176343 745 5        0
     111176343 746 .        .
    1117124372 734 4        0
    1117124372 736 4        0
    1117124372 737 .        0
    1117124372 738 .        0
    1117124372 745 5        0
    1150399278 744 5        0
    1150399278 745 5        0
    1153475375 734 3        0
    1153475375 735 3        1
    1160925440 733 4        0
    1160925440 737 4        1
    1224729496 733 2        0
    1224729496 735 .        1
    1239207297 744 5        0
    1239207297 745 5        0
    1296936529 729 5        0
    1296936529 741 5        0
    1384842385 738 5        0
    1384842385 745 5        0
    1384842385 746 1        0
    1403917287 735 5        1
    1403917287 736 4        0
    1403917287 737 .        0
    1403917287 745 .        0
    1411310422 734 4        0
    1411310422 735 4        0
    1411310422 737 .        0
    1411310422 738 .        0
     143084194 736 3        0
     143084194 745 3        0
    1431500187 726 2        0
    1431500187 739 5        .
    1431500187 740 5        0
    1431500187 743 5        0
    1433775557 726 5        0
    1433775557 729 .        0
    1433775557 732 .        0
    1433775557 733 5        .
    1433775557 734 5        0
    1433775557 736 .        0
    1433775557 739 5        0
    1433775557 741 1        0
    1433775557 743 5        0
    1435284991 726 4        0
    1435284991 728 4        0
    1435284991 729 5        0
    1435284991 730 4        .
    1435284991 731 4        0
    1435284991 732 4        0
    1435284991 733 .        0
    1435284991 734 .        0
    1435284991 745 4        0
    1435284991 746 .        0
    1435284991 747 4        0
    1437450176 729 .        0
    1437450176 730 .        0
    1437450176 731 .        1
    1437450176 734 .        .
    1437450176 735 . .3333333
    
    xtset token1 Datum_n

  • #2
    Look at erepost from SSC. Then replace the variance matrix from the original estimation.

    Comment


    • #3
      Thanks! I will install it and give it a go!

      Comment


      • #4
        If you encounter any difficulties, please include the variable "canton" in your data example and I can provide an illustration. At the moment, your problem is not reproducible.

        Comment


        • #5
          Thanks Andrew! Apologies for the omission. Here it is:

          Code:
          clear
          input long token1 float Datum_n byte verpasstgrouptwosq001 float(canton WFH)
           5410177 736 4 27  .8636364
           5410177 746 4 27         0
          26474014 735 2 18         0
          26474014 737 5 18         0
          26474014 738 5 18         0
          26474014 745 5 18         0
          26474014 746 5 18         0
          44009838 730 5  1         0
          44009838 733 5  1         0
          47287589 735 4 27         0
          48802202 729 4 27         0
          48814183 727 5 20         0
          48814183 731 5 20         0
          48814183 732 4 20         0
          48814183 733 4 20         1
          48814183 734 4 20         0
          48814183 735 3 20        .5
          48814183 736 4 20         1
          48814183 737 4 20         0
          48814183 738 5 20         0
          48814183 740 4 20         0
          48814183 741 4 20         0
          48814183 742 5 20         0
          48814183 743 5 20         0
          48814183 744 5 20         1
          48814183 745 5 20         0
          48814183 746 5 20         0
          48814183 747 5 20         0
          48814275 727 4 27         0
          48814275 745 5 27         0
          48814275 746 5 27         0
          48814945 726 4 27         0
          48814945 732 4 27         0
          48815433 734 2  6         0
          48815433 736 3  6         0
          48815433 739 1  6         0
          48815433 741 1  6         0
          48815433 742 1  6         0
          48815433 745 1  6         0
          48815433 747 5  6         0
          48815821 727 3 27         0
          48815918 726 5 19         0
          48815918 730 4 19         0
          48816024 738 4 27         0
          48816024 739 5 27         1
          48816333 729 5 19         0
          48816753 737 4  6         0
          48816753 741 4  6         0
          48816753 747 4  6         0
          48817271 732 4 13         0
          48817271 745 2 13         0
          48817271 746 4 13         0
          48817279 727 5 20         0
          48818343 744 4  1         0
          48819851 727 5  6         0
          48819866 730 4 13         0
          48819866 738 4 13         0
          48819866 739 4 13         0
          48819866 741 2 13         0
          48819866 745 2 13         0
          48819866 747 4 13         0
          48820293 736 3  4         0
          48820293 747 1  4         0
          48820731 734 4 10         0
          48820731 735 5 10         0
          48820731 737 5 10         0
          48820731 745 5 10         0
          48820731 746 5 10         0
          48822051 732 4  1         0
          48822051 734 5  1         1
          48822051 738 3  1         0
          48822051 744 4  1         0
          48822393 729 4  6         0
          48822393 747 2  6         0
          48822581 727 4 27         0
          48822581 733 5 27         0
          48822581 739 4 27         1
          48822581 741 4 27         0
          48822581 743 3 27         0
          48822853 738 4 21         0
          48822865 732 4 27         0
          48822865 741 4 27         0
          48822865 744 4 27         0
          48822865 745 4 27         0
          48822917 733 5 13         0
          48823581 726 5 17 .16666667
          48823581 738 5 17         0
          48823581 742 5 17         0
          48823581 745 5 17  .6363636
          48823702 726 2 17 .16666667
          48823702 730 4 17         0
          48824481 729 4  4         0
          48825188 731 5 21         0
          48825188 734 5 21         0
          48825188 735 5 21         0
          48825188 737 5 21         0
          48825188 738 5 21         0
          48825971 742 5 13         0
          48825971 744 5 13         0
          48825971 747 5 13         0
          end
          format %tmCYN Datum_n
          
          xtset token1 Datum_n

          Comment


          • #6
            I have the latest version of reghdfe from GitHub, but I keep on getting the following error if I run the example above.

            . boottest WFH=0, seed(1234567890) reps(9999) weighttype(rademacher) bootcluster(canton) boottype(wild) nograph
            boottype(wild) not accepted after Maximum Likelihood-based estimation.
            r(198);
            Perhaps it works fine in an older version. For this problem, as you have just one set of indicators absorbed, we can use regress.

            Code:
            clear
            input long token1 float Datum_n byte verpasstgrouptwosq001 float(canton WFH)
             5410177 736 4 27  .8636364
             5410177 746 4 27         0
            26474014 735 2 18         0
            26474014 737 5 18         0
            26474014 738 5 18         0
            26474014 745 5 18         0
            26474014 746 5 18         0
            44009838 730 5  1         0
            44009838 733 5  1         0
            47287589 735 4 27         0
            48802202 729 4 27         0
            48814183 727 5 20         0
            48814183 731 5 20         0
            48814183 732 4 20         0
            48814183 733 4 20         1
            48814183 734 4 20         0
            48814183 735 3 20        .5
            48814183 736 4 20         1
            48814183 737 4 20         0
            48814183 738 5 20         0
            48814183 740 4 20         0
            48814183 741 4 20         0
            48814183 742 5 20         0
            48814183 743 5 20         0
            48814183 744 5 20         1
            48814183 745 5 20         0
            48814183 746 5 20         0
            48814183 747 5 20         0
            48814275 727 4 27         0
            48814275 745 5 27         0
            48814275 746 5 27         0
            48814945 726 4 27         0
            48814945 732 4 27         0
            48815433 734 2  6         0
            48815433 736 3  6         0
            48815433 739 1  6         0
            48815433 741 1  6         0
            48815433 742 1  6         0
            48815433 745 1  6         0
            48815433 747 5  6         0
            48815821 727 3 27         0
            48815918 726 5 19         0
            48815918 730 4 19         0
            48816024 738 4 27         0
            48816024 739 5 27         1
            48816333 729 5 19         0
            48816753 737 4  6         0
            48816753 741 4  6         0
            48816753 747 4  6         0
            48817271 732 4 13         0
            48817271 745 2 13         0
            48817271 746 4 13         0
            48817279 727 5 20         0
            48818343 744 4  1         0
            48819851 727 5  6         0
            48819866 730 4 13         0
            48819866 738 4 13         0
            48819866 739 4 13         0
            48819866 741 2 13         0
            48819866 745 2 13         0
            48819866 747 4 13         0
            48820293 736 3  4         0
            48820293 747 1  4         0
            48820731 734 4 10         0
            48820731 735 5 10         0
            48820731 737 5 10         0
            48820731 745 5 10         0
            48820731 746 5 10         0
            48822051 732 4  1         0
            48822051 734 5  1         1
            48822051 738 3  1         0
            48822051 744 4  1         0
            48822393 729 4  6         0
            48822393 747 2  6         0
            48822581 727 4 27         0
            48822581 733 5 27         0
            48822581 739 4 27         1
            48822581 741 4 27         0
            48822581 743 3 27         0
            48822853 738 4 21         0
            48822865 732 4 27         0
            48822865 741 4 27         0
            48822865 744 4 27         0
            48822865 745 4 27         0
            48822917 733 5 13         0
            48823581 726 5 17 .16666667
            48823581 738 5 17         0
            48823581 742 5 17         0
            48823581 745 5 17  .6363636
            48823702 726 2 17 .16666667
            48823702 730 4 17         0
            48824481 729 4  4         0
            48825188 731 5 21         0
            48825188 734 5 21         0
            48825188 735 5 21         0
            48825188 737 5 21         0
            48825188 738 5 21         0
            48825971 742 5 13         0
            48825971 744 5 13         0
            48825971 747 5 13         0
            end
            format %tmCYN Datum_n
            
            xtset token1 Datum_n
            regress verpasstgrouptwosq001 WFH i.Datum_n, absorb(token)           
            boottest WFH=0, seed(1234567890) reps(9999) weighttype(rademacher) bootcluster(canton) boottype(wild) nograph
            mat V= e(V)
            mat V[1,1]=((r(CI)[1,1]+ r(CI)[1,2])/3.92)^2
            *ssc install erepost, replace
            erepost V=V
            outreg2 using myfile, replace keep(WFH) nocons

            Comment


            • #7
              Thanks Andrew!

              And my bad by the way, I made a mistake in my formula (the error rests exclusively with me) to convert CI bounds in standard errors, I wrote:

              ((r(CI)[1,1]+ r(CI)[1,2])/3.92)^2 Instead of
              ((r(CI)[1,2]- r(CI)[1,1])/3.92)^2 Just correcting my mistake in case someone else would want to reproduce the code.

              Comment

              Working...
              X