Announcement

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

  • Change order of Bars in combomarginsplot

    Hello. I am running a simple regression, and I want to plot the marginal means of my results

    I am doing something like this.
    Code:
    * create relevant data: car brands
    sysuse auto
    encode make, generate(make_en)
    gen brand = word(make, 1)
    encode brand, generate(brand_en)
    
    * run main regression to examine the effect of brand on price
    reg price ib1.brand_en
    * estimate marginal means of brand on price.
    margins brand_en, post saving(brand_marg, replace)
    Now, my objective is to plot marginal means, and I do the following.
    Code:
    combomarginsplot brand_marg, scale(0.60) scheme(s1color) recast(scatter) ylabel(,grid) plotregion(margin(vlarge)) ytitle("Price" "Marginal means") xtitle("") title("")
    Which works well and produces this plot.
    Click image for larger version

Name:	Screenshot 2023-09-07 at 17.17.29.png
Views:	1
Size:	47.1 KB
ID:	1726332
    How can I change the order of the coefficient bars in my combomarginsplot? For instance, Cad. and Linc. have very high prices: how can I put them at the start of my combomarginsplot?

    thanks a lot in advance for your help

  • #2
    I am just seeing this. You do not in fact need -combomarginsplot- to produce this, as this is simply a graph from a single call to margins, not a graph that combines the results of several calls to -margins-.

    The ordering in the graph is based on the ordering created by -encode-. You could explore -sencode- (a user-contributed SSC package) if you need more control over the encoding order.

    Comment

    Working...
    X