Announcement

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

  • Graphing a nonlinear fit line

    Dear Statalist,

    I'm trying to make a graph of a nonlinear function overlayed on an OLS line. When I run the code below, I get the attached figure. Despite experimenting with various options (e.g., -connected-), I can't get function to display smoothly. What am I doing wrong?

    Thanks!

    -nick

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	257.3 KB
ID:	1329058
    nl log4: mw yr if id==2, initial(b0 1616 b1 5830) vce(robust) nolog
    predict caLog4

    graph twoway (scatter mw yr) (lfit mw yr) (line caLog4 yr) if id==2, tline(2003, lstyle(dot)) ///
    title("California Wind Capacity") ///
    ytitle("MW") ///
    xtitle("") ///
    legend(ring(1) pos(6) order(1 "Wind Capacity (MW)" 2 "Linear" 3 "Logistic")) ///
    graphregion(color(white) ) plotregion( color(white))

  • #2
    I think you just need to add the -sort- option to your -line- command.

    Comment

    Working...
    X