Announcement

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

  • Use of name() option messing up formatting with marginsplot

    I am trying to use margins and marginsplot to convey some logistic regression results. Because of the number of categorical variables at which I want to convey results, I am using the graphdimension() option for marginsplot, to get separate plots I can then combine. But for some reason, when I use the name() option, to pass an explicit name stub, marginsplot begins to ignore other formatting specifications. In particular, specifications for y axis labels and x axis label angles. Why does this happen?

    Please see the reproducible example below. I use Stata 17 on Windows 10. Though this same issue exists when I run the below code on Stata 15 and Stata 16 (still on Windows 10).

    Code:
    clear
    sysuse auto
    
    label values foreign
    
    sum price
    gen expensive = price >= r(mean)
    label define expensive 0 "Cheap" 1 "Expensive"
    label values expensive expensive
    
    sum weight
    gen heavy = weight >= r(mean)
    label define heavy 0 "Light" 1 "Heavy"
    label values heavy heavy
    
    sum mpg
    gen guzzler = mpg >= r(mean)
    label define guzzler 0 "Efficient" 1 "Inefficient"
    label values guzzler guzzler
    
    logit foreign i.expensive i.heavy i.guzzler
    margins, at(heavy = (0 1) expensive = (0 1) guzzler = (0 1))
    
    * When name() isn't used, y labels and x label angle are respected in each graph
    marginsplot, graphdimension(guzzler) bydimension(heavy) xdimension(expensive) noci recast(bar) ylabel(0(0.2)1) xlabel(,angle(45)) //name(something, replace)
    
    * When name() is used, y labels and x label angle are no longer respected in any graph
    marginsplot, graphdimension(guzzler) bydimension(heavy) xdimension(expensive) noci recast(bar) ylabel(0(0.2)1) xlabel(,angle(45)) name(something, replace)
Working...
X