Announcement

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

  • Coefficient as legend in graph??

    Hi!

    I there a way to insert a coefficient from the linear regression as legend in a graph? In this case, 0.0309 (rounded with two decimals) and 0.351... from the multivariate regression.

    Click image for larger version

Name:	Coefficient.JPG
Views:	1
Size:	29.7 KB
ID:	1734507


    Click image for larger version

Name:	Coef2.JPG
Views:	1
Size:	60.2 KB
ID:	1734508


    quietly regress Total_CO2 HGB
    quietly eststo bivariate: margins, at(HGB=(60(20)200)) post
    quietly regress Total_CO2 HGB AGE DATUM i.SEASON
    quietly eststo multivariate: margins, at(HGB=(60(20)200)) post
    coefplot bivariate multivariate, at ytitle(CO2) xtitle(HGB) ///
    recast(line) lwidth(*2)
    Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	26.4 KB
ID:	1734506

    Last edited by Anna Stubbendorff; 20 Nov 2023, 12:43.

  • #2
    coefplot is from SSC, as you are asked to explain in FAQ Advice #12.

    Code:
    sysuse auto, clear
    regress mpg weight, robust
    local betahat1= `:di %5.4f _b[weight]'
    quietly eststo bivariate: margins, at(weight=(1760(200)4840)) post
    
    
    regress mpg weight disp turn i.rep78 i.foreign, robust
    local betahat2=  `:di %5.4f _b[weight]'
    quietly eststo multivariate: margins, at(weight=(1760(200)4840)) post
    
    coefplot bivariate multivariate, at leg(order(1 "{it:m}{sub:1}=`betahat1'" 2 "{it:m}{sub:2}=`betahat2'")) recast(line) noci
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	22.9 KB
ID:	1734519

    Comment

    Working...
    X