Announcement

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

  • twoway scatter plot

    Dear All,

    I have a problem that is making me crazy. I use the following command line:

    twoway (scatter wlnyw pc if pc<=5||lfit wlnyw pc if pc<=5)

    It works fine.

    However if I write:

    twoway (scatter wlnyw pc if pc<=5||lfit wlnyw pc if pc<=5), ytitle(per worker GDP) xtitle(Political competition) title(Political Competition and per workek GDP when pc<=5)

    I got the error message " 5| invalid name"

    In addition if I drop the fitted line and I write:

    twoway (scatter wlnyw pc if pc<=5), ytitle(per worker GDP) xtitle(Political competition) title(Political Competition and per workek GDP when pc<=5)

    it works fine.

    What am I doing wrong?

    Thanks in advance

    ADDENDUM

    I discovered that I get what I need if I use:

    twoway (scatter wlnyw pc if pc<=5) (lfit wlnyw pc if pc<=5), ytitle(per worker GDP) xtitle(Political competition) title(Political Competition and per workek GDP when pc<=5)

    I cannot understand the logic. Why adding additional information into the command line:

    twoway (scatter wlnyw pc if pc<=5||lfit wlnyw pc if pc<=5), ytitle(per worker GDP) xtitle(Political competition) title(Political Competition and per workek GDP when pc<=5)

    does it not work?
    Last edited by Dario Maimone Ansaldo Patti; 05 May 2017, 05:16.

  • #2
    You are combining two different syntanes: () and ||
    If you had typed
    twoway scatter wlnyw pc if pc<=5 || lfit wlnyw pc if pc<=5, ytitle(per worker GDP) xtitle(Political competition) title(Political Competition and per workek GDP when pc<=5)
    it would have worked
    Detail: you begin with a ( and then you switch to || where Stata is waiting for a ). Therefore, Stata interprets 5| as a name

    Comment


    • #3
      Pages 6 and 7 of the twoway manual explain the notation differences: http://www.stata.com/manuals13/g-2gr...g-2graphtwoway
      Last edited by Josh Clothiaux; 05 May 2017, 06:53.

      Comment

      Working...
      X