Announcement

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

  • How should I fix this error in my scatter plot?

    Hello,

    I've been trying to make a more advanced scatter plot and have managed to figure out the bits and pieces of it. Essentially, I want the burden of disease on the y axis and GDP on the x axis, with horizontal and vertical lines going through their averages. I also want to weight the circles by population and have the country's names show up. However, I am having some issues when I put my individual codes together.

    (I have added a photo of the graph I would like to produce)


    One of my issues has been:
    country: may not use time-series operators on string variables Would someone be able to give me insight into how to surpass this error?

    Also, would somebody have tips on the order so that the graph can look like my drawing? This is my current code:

    input *Merged Data Set using "Combine Datasets" Button* *Generate log of both X & Y Variables* generate log_dalys = log(dalys) *Find Means of both X & Y Variables* summarize log_dalys // mean = 8.868019 summarize log_nhexp_reh // mean = 16.7221 *Making Scatter Plot* scatter log_dalys log_nhexp_reh mlabel(country) msymbol(circle_hollow) [w=pop] || lfit dalys nhexp_reh || yline(8.868019) xline(16.7221) end
    Click image for larger version

Name:	Reddit.jpg
Views:	1
Size:	367.8 KB
ID:	1651933


    My data set looks similar to this:
    USA 2016 100 100 1 150 2
    USA 2017 200 150 2 150 2
    USA 2018 300 200 3 150 2
    Korea 2016 100 100 1 150 2
    Korea 2017 200 150 2 150 2
    Korea 2018 300 200 3 150 2

  • #2
    Please read the FAQ on how to ask a question.

    As it stands, I have little to no idea about what I'm looking at here and couldn't reproduce any of this on Stata if I wanted to. I don't want to see what your dataset looks similar to, I want to see your real data, using dataex. I also want to see the code, in context, you've tried with this dataset.

    Handwritten pictures, tables and lots of textual explanations rarely help anybody to solve any Stata problem. Stata is a code based language, so we need to see both data and code. I know there's an answer to this, but you gotta help me, help you.

    If nobody's told you yet, welcome to Statalist.

    Comment


    • #3
      I agree with Jared Greathouse that this is hard to follow. Reading the FAQ Advice would also have flagged that we ask you to tell us about cross-posting. Cross-posting is none of our business -- except that not telling us about it can waste time (yours and ours) and erode good will.

      The thread at https://www.reddit.com/r/stata/comme...ing_variables/ seems further advanced than this thread, so people should please glance at it before deciding whether to give Kelly different advice.

      You did give this code

      Code:
      scatter log_dalys log_nhexp_reh mlabel(country) msymbol(circle_hollow) [w=pop] || lfit dalys nhexp_reh || yline(8.868019) xline(16.7221)
      and Reddit contributors already gave suggestions on the most obvious errors, the need for commas before option calls. There is at least one other mistake: the weights should be specified before the options.

      Comment

      Working...
      X