Announcement

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

  • weights and two way fixed effects in xtqreg

    I am using xtqreg command in Stata to implement a quantile regression. I have two questions:

    (1) How can I add weight for each observation in the regression? aweight does not work in xtqreg.

    (2) How can I have two fixed effects? I want to have both year and id fixed effects.
    Last edited by Hamidreza Bakhtiarizadeh; 07 Apr 2023, 23:45.

  • #2
    Cross-posting (as suggested, but without a flag) of https://stackoverflow.com/questions/...ects-in-xtqreg

    Comment


    • #3
      Hi Hamidreza
      try mmqreg. (Ssc) Implements the same estimator but allows for weights and multiple fixed effects
      Fernando

      Comment


      • #4
        Hi FernandoRios,

        Thank you for making mmqreg available for us! it appears that pweights are not allowed. I am wondering, is there any theoretical reason to not include it as an option?

        Comment


        • #5
          None. It’s probably something I need to modify
          simply try
          w=weight and robust

          Comment


          • #6
            Thank you FernandoRios for your prompt response! Got it.
            I need to use pweights rather than aweights, so unfortunately your suggestion won't work. I will look into the adofile and see if I can tweak around to allow pweights.

            Comment


            • #7
              I understand that, but pweights and just "weights" with Robust will give you the same result.
              The only reason I kept AW on mmqreg, its because its more flexible for other stuff i need to do in the program.
              the estimation itself doesnt use the Standard errors from the regressions, it recreates them manually.
              F

              Comment


              • #8
                Hi FernandoRios,
                I guess I am misunderstanding your suggestion? so your suggestion,
                Code:
                w=weight
                with robust option results in the identical estimates as
                Code:
                aw=weight
                without robust option.
                Are you saying that the weights option in mmqreg always use pweights??

                Rather than using my data, although I know it doesn't have sampling weights in it, here I use the nlswork dataset that you used in your mmqreg page, just for demonstration:
                Code:
                webuse nlswork, clear
                
                . mmqreg ln_w ttl_exp tenure not_smsa south [w=age], abs(idcode) robust
                (sampling weights assumed)
                (24 missing values generated)
                WARNING: some fitted values of the scale function are negative
                Consider using a different model specification
                17 Observations have negative predicted Scale values
                MM-qreg Estimator
                Number of obs = 28093
                Quantile:  50
                ------------------------------------------------------------------------------
                             |               Robust
                     ln_wage | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                location     |
                     ttl_exp |   .0234697   .0008002    29.33   0.000     .0219013     .025038
                      tenure |   .0115601   .0009787    11.81   0.000     .0096418    .0134784
                    not_smsa |  -.0972124   .0110891    -8.77   0.000    -.1189466   -.0754782
                       south |  -.0663628   .0126408    -5.25   0.000    -.0911384   -.0415872
                       _cons |   1.556874   .0068966   225.75   0.000     1.543356    1.570391
                -------------+----------------------------------------------------------------
                scale        |
                     ttl_exp |   .0005567   .0004696     1.19   0.236    -.0003637    .0014771
                      tenure |  -.0047032   .0005822    -8.08   0.000    -.0058442   -.0035621
                    not_smsa |  -.0031209   .0063986    -0.49   0.626    -.0156619    .0094201
                       south |  -.0092352   .0073213    -1.26   0.207    -.0235846    .0051142
                       _cons |   .1985896   .0039068    50.83   0.000     .1909324    .2062468
                -------------+----------------------------------------------------------------
                qtile        |
                     ttl_exp |   .0235019      .0008    29.38   0.000     .0219338    .0250699
                      tenure |    .011288   .0009809    11.51   0.000     .0093654    .0132106
                    not_smsa |  -.0973929   .0110596    -8.81   0.000    -.1190693   -.0757165
                       south |   -.066897   .0126719    -5.28   0.000    -.0917336   -.0420605
                       _cons |   1.568362   .0071953   217.97   0.000     1.554259    1.582464
                ------------------------------------------------------------------------------
                
                
                . mmqreg ln_w ttl_exp tenure not_smsa south [aw=age], abs(idcode)
                (24 missing values generated)
                WARNING: some fitted values of the scale function are negative
                Consider using a different model specification
                17 Observations have negative predicted Scale values
                MM-qreg Estimator
                Number of obs = 28093
                Quantile:  50
                ------------------------------------------------------------------------------
                     ln_wage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                location     |
                     ttl_exp |   .0234697   .0007323    32.05   0.000     .0220343     .024905
                      tenure |   .0115601   .0008782    13.16   0.000     .0098389    .0132813
                    not_smsa |  -.0972124   .0113173    -8.59   0.000    -.1193939   -.0750309
                       south |  -.0663628   .0129058    -5.14   0.000    -.0916576    -.041068
                       _cons |   1.556874   .0071701   217.13   0.000      1.54282    1.570927
                -------------+----------------------------------------------------------------
                scale        |
                     ttl_exp |   .0005567   .0004888     1.14   0.255    -.0004014    .0015148
                      tenure |  -.0047032   .0005862    -8.02   0.000    -.0058521   -.0035543
                    not_smsa |  -.0031209   .0075545    -0.41   0.680    -.0179275    .0116856
                       south |  -.0092352   .0086148    -1.07   0.284    -.0261199    .0076496
                       _cons |   .1985896   .0047862    41.49   0.000     .1892088    .2079703
                -------------+----------------------------------------------------------------
                qtile        |
                     ttl_exp |   .0235019   .0007341    32.02   0.000     .0220631    .0249406
                      tenure |    .011288   .0008814    12.81   0.000     .0095605    .0130156
                    not_smsa |  -.0973929   .0113443    -8.59   0.000    -.1196274   -.0751584
                       south |   -.066897   .0129368    -5.17   0.000    -.0922528   -.0415413
                       _cons |   1.568362   .0074375   210.87   0.000     1.553785    1.582939
                ------------------------------------------------------------------------------
                
                
                .
                Would you mind clarifying your suggestion a bit?
                Thank you!



                Comment


                • #9
                  So, MMQREG uses "AW" just on the surface. Internally, AW were easier to use for some other process like demeaning.
                  Now Standard errors
                  The default option (not robust) uses standard errors that correct for a specific type of heteroskedasticity. Think GLS standard errors (for exact formulas, check Machado and Santos-Silva paper in the references)
                  When you use Robust (with weights) I use an equivalent to the Sandwich Formula Heteroskedasticity consistent. You can also think of it as GMM Standard errors.
                  Cluster Standard errors also follows GMM clustered Standard errors
                  For what you need to work with. using PW is the equivalent to using AW with Robust. That is what i do here.

                  Comment


                  • #10
                    Ah, I see! I now fully understood. Thank you very much for your prompt and detailed explanation FernandoRios!

                    Comment

                    Working...
                    X