Announcement

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

  • Plotting coefficient for a single variable from multiple models

    I want to plot the single coefficient for treatment from multiple regressions on one graph- I am trying to figure out how to do that. I have several outcome variables that I regress on 'treatment' and other controls (mostly looking at log-odds and marginal effects). I want a graph that shows the effect of being treated on various outcome variables.

    Just as an example

    Code:
     sysuse auto, clear
     foreach var in mpg trunk length turn {  
    quietly regress `var' price //assume price is the "treatment" variable  
    estimates store `var'
     }
    I want a graph that shows the coefficient on price for each of the four regressions on a single graph.

    I understand that the units will be different on each of the outcome variables, but this is for illustration only. Think of this as if I want to plot log-odds from multiple logit regressions where outcome variables are all binary and I am trying to see effect of treatment on probability (or log odds) of being 1 versus 0.


    The idea is to create a graph like the one below.

    Last edited by Fatima Alvi; 03 Oct 2018, 05:26.

  • #2
    You can do this with Ben Jann's 'coefplot', available on SSC.
    the steps would be to store parameter estimates after ach regression using est sto, then plot them all using coefplot.
    coefplot is extremely flexible, takes options to use stored estimates by name,, to drop/keep individual parameters including constrants, to change base levels, and to rescale.
    there is a learning curve but I found it well worth it.

    Comment


    • #3
      Originally posted by George Hoffman View Post
      You can do this with Ben Jann's 'coefplot', available on SSC.
      the steps would be to store parameter estimates after ach regression using est sto, then plot them all using coefplot.
      coefplot is extremely flexible, takes options to use stored estimates by name,, to drop/keep individual parameters including constrants, to change base levels, and to rescale.
      there is a learning curve but I found it well worth it.
      Hi George

      I have seen the coefplot command and infact the image above is taken from one of the presentations by Ben. Unfortunately I could only find a way to plot multiple models when the outcome variable is the same but the independent variables change, whereas I want to plot coefficients when the outcome variable changes but the independent variable is the same.
      Last edited by Fatima Alvi; 03 Oct 2018, 05:52.

      Comment


      • #4
        Code:
        sysuse auto, clear
        replace weight = weight/100
        loc i = 1
        foreach dv in weight headroom turn trunk mpg {    
            regress `dv' price i.for
            est sto m`i'
                *build macro for coefplot
                loc cc `"`cc' (m`i', label(Model `i' for Price)) "'
            loc `++i'
            }
            
            
        **simple
        . coefplot (m1, label(m1)) (m2, label(m2))  ///
              , keep(price)  xline(0) 
              
              
        **from macro in loop
              di `"`cc'"'
              coefplot `cc', xline(0) keep(price)
        Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

        Comment

        Working...
        X