Announcement

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

  • Labeling interaction terms in coefplot

    Hi,

    I am trying to create a coefficient plot using just an interaction term that interacts a dummy variable and a year, but the labels are rather busy while I just want them to read as the year.

    Below is the code I used for the regression and coefplot:

    Code:
    reg employed i.num_kids##i.year age i.statefip [pw=wtsupp]
    est sto model9
    
    
    coefplot model9, keep(*.num_kids#*.year) coeflabels(1.num_kids##2000year= "2000")
    I've also attached the coefplot that was generated below. As opposed to "2 or more kids#year=1981" I want the label to just read "1981".

    Thanks in advance for any help.
    Click image for larger version

Name:	Coef_graph_example.jpg
Views:	1
Size:	55.7 KB
ID:	1662111

  • #2
    coefplot is from SSC (FAQ Advice #12). Write a regex for the coefficient names.

    Code:
    webuse grunfeld
    xtreg invest c.mvalue#i.year
    set scheme s1mono
    coefplot, drop(_cons) nolab saving(gr1, replace)
    coefplot, drop(_cons) nolab rename(^.*([1][9][0-9][0-9])\.year\#c\.mvalue$ = \1, regex) saving(gr2, replace)
    gr combine gr1.gph gr2.gph
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	52.7 KB
ID:	1662117

    Comment


    • #3
      Hi Andrew,

      Thank you so much, regex solved my issue!

      Comment

      Working...
      X