Announcement

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

  • Testing Interaction effect in fixed-effect Quantile regression for panel data?

    Dear Stata Statisticians,

    I have one unbalanced panel data in which N is more than 20,000 and T is 5. I have one model specification:
    Code:
     Y=c+aX+bZ+dX*Z
    where Y is continuous variable;
    X is continuous variable;
    Z is also continuous variable;
    X*Z is the interaction item of X and Z.

    As far as I know, there is one command for fixed-effect quantile regression proposed by Powell (2015). When I code, for example:
    Code:
     qregpd y c.c_x c.c_z c.c_x#c.c_z, quantile(0.2) identification(id) fix(year)
    
    *where c_x is the centered x;c_z is the centered z.*


    I expect that this could work as the same as OLS with fixed-effect but I received the error message:
    factor variables and time-series operators not allowed
    r(101);

    My question is " Should I manually create this interaction and then run the fixed-effect quantile regression again?" Thank you so much.

    Best regards,
    David

    Reference:
    Powell, David. 2015. Quantile Regression with Nonadditive Fixed Effects. RAND Labor and Population Working Paper.
    Last edited by David Wong; 30 Mar 2017, 07:00.

  • #2
    My question is " Should I manually create this interaction and then run the fixed-effect quantile regression again?" Thank you so much.
    Probably. The command is user-written and does not support factor-variable notation. So you have to create your own interaction variables to use it.

    However, running -findit fixed effects quantile regression- turns up a couple of other packages that may be newer, and might support factor variable notation. I don't know if the actually do, but it's probably worth your while to look into them and find out. If what they estimate is the model you are looking for, I think the benefits of being able to use factor-variable notation and -margins- are well worth the trouble of downloading and learning a new command.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Probably. The command is user-written and does not support factor-variable notation. So you have to create your own interaction variables to use it.

      However, running -findit fixed effects quantile regression- turns up a couple of other packages that may be newer, and might support factor variable notation. I don't know if the actually do, but it's probably worth your while to look into them and find out. If what they estimate is the model you are looking for, I think the benefits of being able to use factor-variable notation and -margins- are well worth the trouble of downloading and learning a new command.
      Dear Clyde,

      Thank you so much for your kind help again. I am sorry to be unable to reply in time. You are right. I agree with you that it is doable to manually create the interaction. I also have contacted with the author who gave me as the same answer as you gave me.

      Best regards,
      David

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Probably. The command is user-written and does not support factor-variable notation. So you have to create your own interaction variables to use it.

        However, running -findit fixed effects quantile regression- turns up a couple of other packages that may be newer, and might support factor variable notation. I don't know if the actually do, but it's probably worth your while to look into them and find out. If what they estimate is the model you are looking for, I think the benefits of being able to use factor-variable notation and -margins- are well worth the trouble of downloading and learning a new command.
        Dear Clyde,

        Can you detail or provide some materials to show how to manually create the interaction variables?

        Thanks

        Guobao
        Last edited by guobao song; 03 May 2019, 02:32.

        Comment


        • #5
          In the context of the question posed in #1, we are dealing with the interaction of two continuous variables. In that case it's very simple:

          Code:
          gen interaction = x * z
          Then you include x, z, and interaction as predictors in the model.

          With discrete variables it's a bit more complicated. Probably the simplest way to do it is to use the -xi- command (which is what Stata used before factor-variable notation was introduced, but is still available). If x and z are both discrete:

          Code:
          xi i.x*i.z
          this will generate a series of variables corresponding to different levels of x and z, and different combinations of levels of x and z. All of these variables will have names starting with _I. So then you just include _I* as predictors in the regression model. For additional information, see -help xi-.

          Comment


          • #6
            Thank Clyde for your kind reply.

            Comment


            • #7
              Dear Clyde Schechter
              I was using intercations with qregpd command .I have to use intercation for the following model
              Code:
              reg zscore  CapitalRatio d_MP ROA NIM lasset  c.d_MP##MPR i.Year,robust
              .
              for using qregpd command ,can i insert the intercation of combination of both contionus and categorical varaible ,I tried the below way
              Code:
              xi c.d_MP*MPR
              but I was getting error message ,Can you please help me on this if possible


              Thanking you
              Fadi

              Comment


              • #8
                The syntax of -xi- is different from factor variable notation. From your -reg- command, I'm inferring that MPR is a discrete variable and d_MP is continuous. In that case, to use -xi- to create their interaction the code would be -xi i.MPR*d_MP-. There is no c. prefix in -xi- syntax. And whereas factor variable notation assumes unprefixed variables are discrete, -xi- assumes they are continuous.

                Comment


                • #9
                  Thankyou so much Clyde Schechter .
                  After running the above command,i got the following
                  Code:
                   xi i.MPR*d_MP
                  i.MPR             _IMPR_1-2           (naturally coded; _IMPR_1 omitted)
                  i.MPR*d_MP        _IMPRXd_MP_#        (coded as above)
                  
                  .
                  but now my problem is that when I adding this variable to qregpd command ,Stata shows below
                  Code:
                  qregpd zscore d_MP _IMPR_2*  CapitalRatio NIM ROA lasset MPR ,id(bankname) fix(Year)  optimize(mcmc) noisy draws(1000) burn(100) 
                  > arate(.5) quantile(.9)
                  variable _IMPR_2* not found
                  r(111);
                  .
                  How can I solve this or can you help me to rewrite this coammand

                  Thanking you
                  Fadi

                  Comment


                  • #10
                    I cannot see what you are doing wrong here and I have no explanation.

                    I will point out that the use of the wildcard expression _IMPR_2* seems odd here in that it should expand only to the single variable _IMPR_2, and will not include the interaction term. I would have thought you would want to include _I*, which would expand to both the MPR = 2 indicator and the interaction.

                    But, still, _IMPR_2 is, as far as I can see, legal syntax, and I cannot see why the variable is not found. Perhaps somewhere between the -xi- command and the -qregpd- command you did something that removed the variable from your data set? For example, if you -preserve-d the data before the -xi- command, and then it got -restore-d (either by a -restore- command or by default) before the -qregpd- command, that would cause the _I* variables to disappear. I think for more help you need to post example data (use -dataex-) and the complete code all the way from before the -xi- command to the -qregpd-.

                    Comment


                    • #11
                      Thankyou so much .I got the following results but the _IMPR is still showing not found.
                      Code:
                      qregpd assetrisk d_MP  _IMPRXd_MP*   CapitalRatio NIM ROA lasset MPR ,id(bankname) fix(Year)  optimize(mcmc) noisy draws(1000) burn(
                      > 100) arate(.5) quantile(.9)
                      Adaptive MCMC optimization
                      ................................................. 50: f(x) = -27.6462629
                      ................................................. 100: f(x) = -30.2641268
                      ................................................. 150: f(x) = -29.8128271
                      ................................................. 200: f(x) = -26.8655985
                      ................................................. 250: f(x) = -25.1174439
                      ................................................. 300: f(x) = -27.012698
                      ................................................. 350: f(x) = -29.1013952
                      ................................................. 400: f(x) = -25.7860883
                      ................................................. 450: f(x) = -24.0217407
                      ................................................. 500: f(x) = -26.256033
                      ................................................. 550: f(x) = -25.1393112
                      ................................................. 600: f(x) = -26.3399306
                      ................................................. 650: f(x) = -28.4472934
                      ................................................. 700: f(x) = -25.7699181
                      ................................................. 750: f(x) = -26.7006845
                      ................................................. 800: f(x) = -28.4477471
                      ................................................. 850: f(x) = -25.7104592
                      ................................................. 900: f(x) = -26.3399306
                      ................................................. 950: f(x) = -25.7860883
                      ................................................. 1000: f(x) = -24.0217407
                      
                      
                      Quantile Regression for Panel Data (QRPD)
                           Number of obs:               774
                           Number of groups:             82
                           Min obs per group:             1
                           Max obs per group:            14
                      ------------------------------------------------------------------------------
                         assetrisk |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                              d_MP |  -.0036727   .0001441   -25.49   0.000    -.0039551   -.0033903
                      _IMPRXd_MP_2 |    .006938   .0007919     8.76   0.000      .005386      .00849
                      CapitalRatio |   .0058512   .0000376   155.76   0.000     .0057775    .0059248
                               NIM |   .0002956   .0001875     1.58   0.115    -.0000719    .0006631
                               ROA |  -.0000199   3.33e-06    -5.98   0.000    -.0000264   -.0000134
                            lasset |  -.0077331   .0001497   -51.66   0.000    -.0080265   -.0074396
                               MPR |   -.008197   .0005726   -14.32   0.000    -.0093192   -.0070747
                      ------------------------------------------------------------------------------
                      No excluded instruments - standard QRPD estimation.
                      
                      
                      MCMC diagonstics:
                           Mean acceptance rate:      0.170
                           Total draws:                1000
                           Burn-in draws:               100
                           Draws retained:              900
                           Value of objective function:   
                                   Mean:             -26.7299
                                   Min:              -34.0454
                                   Max:              -24.0217
                      MCMC notes:
                           *Point estimates correspond to mean of draws.
                           *Standard errors are derived from variance of draws.

                      Comment


                      • #12
                        Dear @Cylde Your answers were higly helpful .My problem solved.
                        I am having one more qurey ,is there any source where I can find the intrepretation of quantile regression using QREGPD

                        Comment


                        • #13
                          I'm afraid I can't help you with that. I'm unfamiliar with this command. Perhaps its help file has sufficient explanations, or references that will help you out. Or perhaps others reading along can respond here.

                          Comment


                          • #14
                            Dear Fadi Ansar,

                            I suggest you read the paper by Powell referred above for the interpretation. Note that the model you estimate with this command is not t standard fixed effects model in the sense that the model does not actually include fixed effects, although they are used in the estimation of the parameters (a bit like instruments are used in the estimation of equations from which they are included).

                            Best wishes,

                            Joao

                            Comment

                            Working...
                            X