Announcement

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

  • Plotting the coefficients of a linear combination

    I have been trying to solve the following problem for days now to no avail. coefplot keep plotting the actual model coefficients rather than the linear combination ones. Would you please help if you have an idea. Thanks a lot!


    sysuse auto, clear

    estimates clear

    eststo domestic: regress price mpg if foreign==0
    eststo domestic_scaled: lincom mpg*10

    eststo foreign: regress price mpg if foreign==1
    eststo foreign_sclaed: lincom mpg*10


    coefplot domestic_scaled foreign_sclaed, drop(_cons) vertical xlabel(, angle(45) labsize(small) grid)

  • #2
    coefplot is from SSC (FAQ Advice #12).

    Originally posted by Renee Dobbs View Post
    coefplot keep[s] plotting the actual model coefficients rather than the linear combination[s].
    The reason is that lincom does not post its results to e(b) and e(V), and it lacks an option that would enable you to do so. I would switch to margins in this case.

    Code:
    sysuse auto, clear
    estimates clear
    eststo domestic: regress price mpg if foreign==0
    margins, dydx(mpg) expression(predict(xb)*10) post
    estimates store domestic_scaled
    
    eststo foreign: regress price mpg if foreign==1
    margins, dydx(mpg) expression(predict(xb)*10) post
    estimates store foreign_scaled
    
    coefplot domestic_scaled foreign_scaled, drop(_cons) vertical xlabel(, angle(45) labsize(small) grid)
    But also note that a linear transformation can be implemented by coefplot using the original estimates and the -transform()- option. In your case:

    Code:
    coefplot domestic foreign, drop(_cons) vertical xlabel(, angle(45) labsize(small) grid) transform(*= @*10)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	21.7 KB
ID:	1751065



    Res.:

    Comment


    • #3
      Andrew Musau The transform method solved my problem perfectly. THANK YOU THANK YOU for taking the time to provide two solutions and helping me address this problem. I am so grateful!

      Comment

      Working...
      X