Announcement

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

  • Plotting regression coefficients

    Hello,

    I’m running a quantile regression using David Powell’s -qregpd- package (SSC) on the 25th, 50th and 75th percentiles of my outcome wb. I am trying to graph the coefficients in a way similar to what coefplot (SSC) does (attached image). I have tried adjusting the code suggested here by Clyde Schechter , but can’t get it right.

    Code:
    forvalues i=0.25(0.5)0.75{
    qregpd WB COVID2 COVID3 COVID4 econ2 econ3 econ4 food2 food3 emp2 emp3 income2 income3 age mar2 mar3 educ2 educ3 educ4 urban2 under_six2 safety_net2, id(Findid) fix(wave) optimize(mcmc) noisy draws(3000) burn(300) arate(.5)
    }
    
    
    capture postutil clear
    tempfile holding
    postfile handle quantile coefficient using `holding'
    
    forvalues i=0.25(0.5)0.75{
        qregpd WB COVID2 COVID3 COVID4 econ2 econ3 econ4 food2 food3 emp2 emp3 income2 income3 age mar2 mar3 educ2 educ3 educ4 urban2 under_six2 safety_net2, id(Findid) fix(wave) optimize(mcmc) noisy draws(3000) burn(300) arate(.5)
        post handle (`i') (_b[COVID2])
    }
    postclose handle
    
    use `holding', clear
    graph hbar coefficient quantile, over(WB)
    The help file says the results are stored in the following way:

    Code:
    qregpd saves the following in e():
     
        Scalars        
          e(N)                number of observations
     
        Macros        
          e(cmd)              "qregpd"
          e(title)            "Quantile Regression for Panel Data"
          e(indepvars)         Righ-hand side variables
          e(depvar)            Left-hand side variable
          e(gamma)             Values on the gamma vector
     
        Matrices      
          e(b)                Parameter values
          e(V)                Variance-covariance matrix of parameters
          e(solutions)        Parameter values from grid search; may contain multiple solutions.
     
        Functions     
          e(sample)           marks estimation sample


    Click image for larger version

Name:	cplot.png
Views:	1
Size:	53.1 KB
ID:	1647873

  • #2
    Just out of curiosity, why not just use coefplot?

    Comment


    • #3
      First time I tried to do it, I got the error no estimates found or all dropped, but now it seems to have worked! Produced the graph I need. Feeling pretty silly, thanks for pointing out the obvious Jared.

      Comment


      • #4
        🤣 we all have moments like that, it just puzzled me when you said you knew about coefplot but didn't want to use it.

        We've all been there before, or at least, I know I have.

        Comment


        • #5
          Have you tried -metan- to plot those estimates? I have used -metan- many times to plot medians (Q1, Q3). You loop over the predictors, collect medians, Q1s and Q3, and plot them using -metan- with the options ooverall nowt nostats.

          Code:
          gene equalweight = 10
          metan median q1 q3, nooverall nowt nostats wgt(equalweight)
          You can add labels, modify sticks and add information on the left- and right-hand sides using the options lcols and rcols.

          All the best,

          Tiago

          Comment


          • #6
            Tiago Pereira Using metan to report summary stats?

            Comment


            • #7
              Yes, in -metan-, we can plot anything that has a point estimate, a lower bound and an upper bound. They can be mean (95% CI), posterior medians (95% Crl) or median (Q1, Q3). Of course, the summary results will make no sense, that is why we have to use the option ooverall nowt nostats.

              Comment


              • #8
                Tiago Pereira I'd never even thought about it like that. So theoretically, it could be used to plot, say, a variety of average treatment effects from a variety of different estimators. I'd never even thought of that, but it seems like a great idea I'd love to experiment with. I'll give it a go.

                Comment

                Working...
                X