Announcement

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

  • Two way line

    I am trying to create a line graphic through stata by using twoway line. Sadly only a part of my formula is working right now
    twoway line Abnormalreturn Year if DummyHedgefundownership==0, color(red)||
    line Abnormalreturn Year if DummyHedgefundownership==1, color(blue) ||
    line Stockreturn Year if DummyHedgefundownership==0, color(green) ||
    line Stockreturn Year if DummyHedgefundownership==1, color(yellow),

    After this , I am trying to create a legenda but it says my parentheses do not balance:
    legend(label(1 "Low hedgefund ownership (Abnormal)") label(2 "High hedgefund ownership (Abnormal)") /// label(3 "Low hedgefund ownership (Stock)") label(4 "High hedgefund ownership (Stock)")) /// ytitle("Return") xtitle("Year") title("Abnormal en Stock Return from 2012-2022 per Hedgefund ownership")

    It either says the command isn't regonized or that the parentheses do not balance.

  • #2
    Too many commas in your code. Also,

    Code:
    ///
    wouldn't be recognized interactively, which might be a problem. Try typing this in a do-file editor window

    Code:
    twoway line Abnormalreturn Year if DummyHedgefundownership==0, color(red) ||  ///
    line Abnormalreturn Year if DummyHedgefundownership==1, color(blue) || ///
    line Stockreturn Year if DummyHedgefundownership==0, color(green) || ///
    line Stockreturn Year if DummyHedgefundownership==1, color(yellow) ///
    legend(label(1 "Low hedgefund ownership (Abnormal)") label(2 "High hedgefund ownership (Abnormal)") ///
    label(3 "Low hedgefund ownership (Stock)") label(4 "High hedgefund ownership (Stock)")) ///
    ytitle("Return") xtitle("Year") title("Abnormal and Stock Return 2012-2022 by Hedgefund ownership")
    Notes:

    0. Here I am assuming that /// occurs at the end of physical lines.

    1. Red and green together are not a good idea because of so-called colour blindness.

    2. Date ranges like from 2012-2022 are deprecated in authoritative style guides for the English language. Either pair from and to -- or (better) omit from altogether.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Too many commas in your code. Also,

      Code:
      ///
      wouldn't be recognized interactively, which might be a problem. Try typing this in a do-file editor window

      Code:
      twoway line Abnormalreturn Year if DummyHedgefundownership==0, color(red) || ///
      line Abnormalreturn Year if DummyHedgefundownership==1, color(blue) || ///
      line Stockreturn Year if DummyHedgefundownership==0, color(green) || ///
      line Stockreturn Year if DummyHedgefundownership==1, color(yellow) ///
      legend(label(1 "Low hedgefund ownership (Abnormal)") label(2 "High hedgefund ownership (Abnormal)") ///
      label(3 "Low hedgefund ownership (Stock)") label(4 "High hedgefund ownership (Stock)")) ///
      ytitle("Return") xtitle("Year") title("Abnormal and Stock Return 2012-2022 by Hedgefund ownership")
      Notes:

      0. Here I am assuming that /// occurs at the end of physical lines.

      1. Red and green together are not a good idea because of so-called colour blindness.

      2. Date ranges like from 2012-2022 are deprecated in authoritative style guides for the English language. Either pair from and to -- or (better) omit from altogether.
      Thanks for your feedback, it worked for some reason an error first occured.
      Last edited by Tobias Boo; 17 Apr 2024, 04:55. Reason: Solved

      Comment

      Working...
      X