Announcement

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

  • Graphing twoway scatter plots

    Dear statalist community,

    I currently have a small problem with performing graphs.

    In the beginning of my analysis I just want to have some basic graphs before I start with the regressions.

    I tried to do twoway scatter plots but they just don't show anything.

    My dependent variable in and my variable that should be shown on the x-axis is risk preferences on a scale for 0-10 and my explanatory variables that should be shown on the y-axis are married /non-married, divorced/not-divorced, widow/not

    For example, married is a dummy variable and risk preferences is categorical.

    Code:
    twoway (scatter married risk_preferences, sort)
    This is what I performed for ever variable and the scatter then always looks the following:

    Click image for larger version

Name:	scatter.PNG
Views:	1
Size:	17.0 KB
ID:	1449793


    any ideas what I am doing wrong?

    If you need more information let me know

    ah and btw I haven't told stata that I'm using panel data, so I did not run the xtset command.

    Best regards

    Lisa

  • #2
    Have you tried changing the opacity of the plotting symbols and adding jitter to the data? You might just be suffering from overplotting.

    Comment


    • #3
      Dave Airey thank for the quick reply. I haven't tried that but to be honest I also don't know how to do that. I would be grateful for an advice on how to do this in stata.

      Comment


      • #4
        I tried omething out now but don't know if that's correct:

        Code:
        twoway (scatter married risk_preferences, sort mcolor(%30) jitter(1))
        Click image for larger version

Name:	scatter 2.PNG
Views:	1
Size:	18.6 KB
ID:	1449802

        so if that's correct then I have still got the same problem :/

        Comment


        • #5
          There isn't a problem with the code or data, the problem is that this isn't a good way to graph these variables. All of your married are either 0 or 1 and risk is 1,2,3 etc. Stata faithfully plots all of these points where they are, which is right on top of each other. A larger jitter(random movement of the points) will get more separation, but doesn't really help you understand the data that much better. Try a histogram split by marriage instead.

          Code:
          ***What you have
          twoway (scatter married risk_preference)
          ****Only a little better
          twoway (scatter married risk_preference, jitter(20))
          ****Better
          hist risk_preference, by(married) discrete

          Comment


          • #6
            See also e.g. https://www.statalist.org/forums/for...updated-on-ssc

            Comment


            • #7
              It is true that the given plot is not the best choice for the problem.

              Code:
              clear
              input y x
              1 1
              1 2
              1 2
              1 3
              2 1
              2 2
              2 3
              2 3
              end
              expand 100
              table y x
              scatter y x, msymbol(oh) mcolor(%30) jitter(7) ///
               xlabel(0(1)4) ylabel(0(1)3)
              hist x, by(y) discrete
              // ssc install tabplot
              tabplot y x

              Comment


              • #8
                Thank you so much for all that help !!!!

                Comment

                Working...
                X