Announcement

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

  • How to make scatterplot based on intervals of a continuous variable ?

    Hello folks, I have a question regarding making a scatterplot representing the % of people identified as should be in intervention based on one continuous score. For instance, I have a binary variable representing whether the people should be placed in intervention and a continuous score (ranging from 30 to 100) representing their skill measured using a instrument. Now I need to make a scatter plot based on intervals of the continuous score, for instance from 30 to 40, 40 to 50, 50 to 60, etc and within each interval, I want to show the distribution of the % of people who should be placed in the intervention using scatters. Anyone can help me with that? Thanks.

  • #2
    This sounds more like a case for a histogram to me. But in what sense do you "need to" make a scatter plot with 10% bins? Why not just plot a smoothed version of your binary variable as a function of the continuous score?

    Comment


    • #3
      Hi Nick, I want to have a scatterplot to show the relationship between the binary variable and the continuous variable. If I only plot the overall distribution of the binary variable, it will only be either 0 or 1, which makes it harder to see the relationship very well. That's why I'm thinking to bin-up the continuous variable and within the bins to show the distribution of the % of the binary variable. How to plot the smooth version like you said?

      Comment


      • #4
        Use any smoother you like. Here's a not totally silly example:


        Code:
        sysuse auto
        lpoly foreign weight, bw(400) biweight ms(Oh) jitter(1)

        Comment


        • #5
          Thanks for the suggestion Nick. I tried your code but it wasn't the plot as I am expecting. However, I found a user-written command called binscatter and it generates the plot exactly as what I want. Below is the example.

          Click image for larger version

Name:	Graph.png
Views:	1
Size:	28.3 KB
ID:	1422154

          Comment


          • #6
            That doesn't look like the data described in #1, but whatever works for your purposes! Disjoint bins tend to work well enough with large sample sizes; otherwise moving windows seem preferable.

            Comment

            Working...
            X