Announcement

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

  • Invalid name error

    Hi

    I am trying to run a quantile regression and then plot the ols and quantile regression coefficients for variable treatment with confidence intervals

    Code:
     grqreg treatment , cons ci ols olsci
    Ran the obove code but keeps showing the error below

    invalid name
    r(198);


    Please help.

  • #2
    since -grqreg- can only be used after a quantile regression command, please show us what the preceding command was as there may be an inconsistency between the commands

    Comment


    • #3
      I am sorry


      Code:
      qreg fee_adjusted i.treatment i.state ib2007.year age i.sector , vce(robust)
      grqreg treatment , cons ci ols olsci
      Error:

      0b.treatment invalid name
      r(198);

      Comment


      • #4
        Akanksha:
        the error rests on the way you called the community-contributed command (as you're kidly requested by FAQ to detail) -grqreg-, as you can see from the following toy-example:
        Code:
        webuse auto, clear
        . qreg price mpg weight headroom
        Iteration  1:  WLS sum of weighted deviations =  68749.068
        
        Iteration  1: sum of abs. weighted deviations =   66982.32
        Iteration  2: sum of abs. weighted deviations =  63996.616
        Iteration  3: sum of abs. weighted deviations =  63956.522
        
        Median regression                                   Number of obs =         74
          Raw sum of deviations  71102.5 (about 4934)
          Min sum of deviations 63956.52                    Pseudo R2     =     0.1005
        
        ------------------------------------------------------------------------------
               price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 mpg |  -77.84984   107.8287    -0.72   0.473    -292.9075    137.2078
              weight |    .456869   .8347793     0.55   0.586    -1.208046    2.121784
            headroom |  -160.2684   497.2776    -0.32   0.748    -1152.057    831.5205
               _cons |   5986.834   4584.871     1.31   0.196    -3157.402    15131.07
        ------------------------------------------------------------------------------
        
        . grqreg, cons ci ols olsci
        As you can see, there are no variables between -grqreg- and comma.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hi Carlo. Thanks for the response.

          Code:
           qreg fee_adjusted i.treatment i.state ib2007.year age i.sector , vce(robust)
          grqreg  , cons ci ols olsci
          When i run the above , the following error is still shown:

          0b.treatment invalid name
          r(198);

          Comment


          • #6
            Akankska:
            what if you run:
            Code:
             
             xi: qreg fee_adjusted i.treatment i.state ib2007.year age i.sector , vce(robust)  
             grqreg, cons ci ols olsci
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              2007b.year invalid name
              r(198);


              Now it shows the above error, Carlo.

              Comment


              • #8
                it appears that -xi- does not allow you to set the baseline (thus, "ibX" is not valid) and that grqreg appears to have a problem with factor variable notation; try just "i.year" instead)

                Comment


                • #9
                  Akankska:
                  being a bit old-fashioned, the community-contributed command -grqreg- does not support -fvvarlist- notation.
                  Therefore, you cannot choose the reference category youeself, but should Stata do it and calculate what you're intrested in according to Stata outcome table.
                  That said, you should go:
                  Code:
                   
                    xi: qreg fee_adjusted i.treatment i.state i.year age i.sector , vce(robust)    grqreg, cons ci ols olsci
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Thanks so much for your help Carlo and Rich. The following code worked.

                    Code:
                    xi: qreg fee_adjusted i.treatment i.state i.year age i.sector [fw=round(weight)] , vce(robust)
                    grqreg  , cons ci ols olsci

                    I have couple of follow up questions too:

                    1) The code shows 37 graphs and I am only interested in one of them which is barely even properly visible. Can something be done?
                    2) I want to also cluster the standard errors at the state level since the treatment is being given at the state level. Can that be done?


                    Thanks so much.

                    Comment


                    • #11
                      Akankska:
                      1) as far as I know, there's no way to magnify the graph you're intrested in;
                      2) no, you can't, as -qreg- does not support the -vce(cluster clusterid)- option for non-default standard error.
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment

                      Working...
                      X