Announcement

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

  • Dear Giorgio Di Stefano,

    As far as I can see in the post you refer to in #208 you are not interested in estimate quantile regressions, so I do not see how xtqreg can be of use to you.

    Best wishes,

    Joao

    Comment


    • Dear Mr. Joao Santos Silva, I just wanted to double-check the validity of an algorithm in the xtqreg framework.

      I've been working with the 'Quantiles-via-Moments' estimator on a panel data set and have recently implemented the jackknife bias correction algorithm that you so kindly shared on your webpage.

      In doing so, I've noticed that the algorithm only performs the bias correction in the 5th decile. Is that correct? Using your own example in the do-file, I've tried to run the following code for the 1st decile coefficient, where I substitute, for example, the matrix V=e(V) for V1=e(V_1), as well as matrix Q50 = e(q) for matrix Q10= e(q_1) -- and all other matrices in the subsamples --, following the guidelines of 'help xtqreg' related to how each vector and matrix of the quantiles is stored, but I still get a conformability error r(503). In your opinion, what would be the best way to adapt it?


      PHP Code:
      clear all
      ssc install xtqreg
      replace

      cls
      webuse nlswork
      xtset idcode

      by idcode
      egen c=count(idcode)
      set seed 123 
      g s
      =runiform()<0.5

      *** Simple MM-QR estimation with fixed effects
      xtqreg ln_w  age ttl_exp tenure  not_smsa south 
      if c>=10ls q(0.10(0.40)0.90)

      *** 
      MM-QR results with JK correction and clustered standard errors
      qui bs 
      if c>=10cluster(idcoderep(20): xtqreg ln_w  age ttl_exp tenure  not_smsa south
      mat V1
      =e(V_1
      matrix b=e(b_location)
      matrix g=e(b_scale)
      matrix Q10=e(q_1
      scalar N=e(N)
      qui xtqreg ln_w  age ttl_exp tenure  not_smsa south if c>=10&s==0  
      scalar N0
      =e(N)
      matrix Q010=e(q_1)
      matrix g0=e(b_scale)
      qui xtqreg ln_w  age ttl_exp tenure  not_smsa south if c>=10&s==1   
      scalar N1
      =e(N)
      matrix Q110=e(q_1)
      matrix g1=e(b_scale)
      mat bjk1=b+(2*g-g1*(N1/N)-g0*(N0/N))*(2*Q10-Q110*(N1/N)-Q010*(N0/N)) 
      ereturn post bjk1 V1
      ereturn display 
      Thank you so much and kind regards,
      Derick

      Comment


      • Dear Derick Almeida,

        Note that the code only works for one quantile at the time, so you can only have one quentile in the option q() and you have to change the names of the matrices for each quantile. Probably there is a more efficient way to do that...

        Also note that selecting observations with c>=10 was specific to that example; you will not need that in your application.

        Best wishes,

        Joao

        Comment


        • Dear Joao Santos Silva,

          thank you for your valuable advice, including the fact that c>=10 is not an essential part of the script when it comes to other datasets . In fact, I reran the code, specifying separately the desired quantiles I needed, and the jackknife correction worked greatly for each one. The code I ran, based again in the do-file, for (let's say) the 1st decile is:

          PHP Code:
          clear all
          ssc install xtqreg
          replace

          cls
          webuse nlswork
          xtset idcode

          by idcode
          egen c=count(idcode)
          set seed 123 
          g s
          =runiform()<0.5

          *** Simple MM-QR estimation with fixed effects
          xtqreg ln_w  age ttl_exp tenure  not_smsa south 
          if c>=10ls q(0.10)

          *** 
          MM-QR results with JK correction and clustered standard errors
          qui bs 
          if c>=10cluster(idcoderep(20): xtqreg ln_w  age ttl_exp tenure  not_smsa southls q(0.10)
          mat V1=e(V
          matrix b=e(b_location)
          matrix g=e(b_scale)
          matrix Q10=e(q
          scalar N=e(N)
          qui xtqreg ln_w  age ttl_exp tenure  not_smsa south if c>=10&s==0ls q(0.10)  
          scalar N0=e(N)
          matrix Q010=e(q)
          matrix g0=e(b_scale)
          qui xtqreg ln_w  age ttl_exp tenure  not_smsa south if c>=10&s==1ls q(0.10)   
          scalar N1=e(N)
          matrix Q110=e(q)
          matrix g1=e(b_scale)
          mat bjk1=b+(2*g-g1*(N1/N)-g0*(N0/N))*(2*Q10-Q110*(N1/N)-Q010*(N0/N)) 
          ereturn post bjk1 V1
          ereturn display 
          Best regards,
          Derick

          Comment


          • Dear Joao Santos Silva, another question has come up regarding xtqreg.

            I want to conduct a linear constraint hypothesis test between two quantile coefficients of the xtqreg regression output, namely the 1st and the 9th deciles, to know if they are statistically different from each other. I have already read earlier posts, in which you recommend bootstrapping the regression, much in the same way as sqreg does. But I've been having som trouble getting the F or chi2 statistics for the test.

            Let me first show my regression and hypothesis test under sqreg. This is just a toy example in which log_LP is the dependent variable, log_RD is the only independent variable and I want to calculate an estimate for the 1st and 9th decile coefficients.

            PHP Code:
            sqreg log_LP log_RDq(0.1,0.9

            (fitting base model)

            Bootstrap replications (20)
            ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
            ....................

            Simultaneous quantile regression Number of obs = 5,237
            bootstrap(20) SEs .10 Pseudo R2 = 0.0786
            .90 Pseudo R2 = 0.0364

            ------------------------------------------------------------------------------
            | Bootstrap
            log_LP | Coef. Std. Err. t P>|t| [95% Conf. Interval]
            -------------+----------------------------------------------------------------
            q10 |
            log_RD | .3659615 .0139983 26.14 0.000 .338519 .393404
            _cons | 2.760837 .0301514 91.57 0.000 2.701728 2.819947
            -------------+----------------------------------------------------------------
            q90 |
            log_RD | .1975607 .0181288 10.90 0.000 .1620207 .2331007
            _cons | 4.826183 .0286634 168.37 0.000 4.769991 4.882376
            ------------------------------------------------------------------------------

            Then, to test whether the 1st and 9th coefficients are statistically the same:

            --------------------------------------------------------------
            PHP Code:
            test [q10=q90] : log_RD 

            ( 1) [q10]log_RD - [q90]log_RD = 0

            F( 1, 5233) = 5.94
            Prob > F = 0.0148
            ---------------------------------------------------------------

            Now, conducting the bootstrap regression for panel data through the xtqreg command, separately for each quantile, we get:

            PHP Code:
            bootstrapreps(20): xtqreg log_LP log_RDq(0.1

            Bootstrap replications (20)
            ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
            ....................

            Bootstrap results Number of obs = 5,237
            Replications = 20

            ------------------------------------------------------------------------------
            | Observed Bootstrap Normal-based
            log_LP | Coef. Std. Err. z P>|z| [95% Conf. Interval]
            -------------+----------------------------------------------------------------
            log_RD | .4139783 .0252642 16.39 0.000 .3644614 .4634953
            ------------------------------------------------------------------------------

            PHP Code:
            bootstrapreps(20): xtqreg log_LP log_RDq(0.9
            Bootstrap replications (20)
            ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
            ....................

            Bootstrap results Number of obs = 5,237
            Replications = 20

            ------------------------------------------------------------------------------
            | Observed Bootstrap Normal-based
            log_LP | Coef. Std. Err. z P>|z| [95% Conf. Interval]
            -------------+----------------------------------------------------------------
            log_RD | .3451415 .0179813 19.19 0.000 .3098987 .3803843
            ------------------------------------------------------------------------------

            At this point, differently from sqreg that offered me equations named q10 and q90 to conduct the F test on the log_RD quantile coefficients, I can't find the right name or reference to use the information of both regressions in xtqreg to conduct the same test. I'm afraid it's because xtqreg does not estimate the equations simultaneously. I've looked into "help xtqreg" to figure out the right way to reference it in the test, but I had no success. Do you have an idea of how to carry on this exercise?

            Thank you so much again.

            All the best,
            Derick

            Comment


            • Dear Derick Almeida

              It may be enough to run xtqreg for any quantile with the option ls. If a variable is significant in the scale function, its coefficients will vary across quantiles.

              To you the bootstrap, what you have to do is to create a small program that estimates the two quantiles and computes the difference between the two coefficients. You then bootstrap that programme.

              Best wishes,

              Joao

              Comment


              • Joao Santos Silva Dear professor,

                I was wondering why, when I implement ". xtqreg Return CPI", why do I obtain :

                "MM-QR regression results

                It is not possible to identify the conditional quantiles with T<3; the estimator is valid onl
                > y for large T"

                Knowing that I have 166 observations. What Can I do to solve this problem?

                Kind regards,
                Matz Justin

                Comment


                • Dear Justin Matz,

                  I assume you have a panel; what are the values of N and T in your dataset?

                  Best wishes,

                  Joao

                  Comment


                  • Joao Santos Silva,

                    I have an excel sheet with 80 variables, in monthly basis, spread over 13 years.
                    Those variables are macroeconomic variables and I want to regress Returns (dependant variable) on each independent variable.

                    Kind regards,
                    Matz Justin

                    Comment


                    • Originally posted by Justin Matz View Post
                      Joao Santos Silva,

                      I have an excel sheet with 80 variables, in monthly basis, spread over 13 years.
                      This sheet is an average of 13 other sheets, each representing a different country.

                      Comment


                      • Dear Justin Matz,

                        Then, just use xtset to define your panel and then use the xtqreg command.

                        Best wishes,

                        Joao

                        Comment


                        • Dear professor Joao Santos Silva,

                          Yeah, it is what I wanted to do, but obtain this error message : "It is not possible to identify the conditional quantiles with T<3; the estimator is valid onl
                          > y for large T"

                          My complete code : ". xtset Date

                          Panel variable: try (weakly balanced)
                          Time variable: Date, 01jan2008 to 01dec2021
                          Delta: 1 day

                          . xtqreg Return CPI



                          MM-QR regression results

                          It is not possible to identify the conditional quantiles with T<3; the estimator is valid onl
                          > y for large T"

                          Do you know how I can solve this issue?

                          Kind regards,
                          Matz Justin

                          Comment


                          • What is the variable "try"?

                            Comment


                            • Sorry, it is an error (somethings that I tried)

                              complete code : ". xtset Date

                              Panel variable: Date (balanced)

                              . xtqreg Return CPI



                              MM-QR regression results

                              It is not possible to identify the conditional quantiles with T<3; the estimator is valid onl
                              > y for large T
                              "

                              Comment


                              • When using xtset, you need to define the id identifier and then the sate; you are not including the id identifier.

                                Comment

                                Working...
                                X