Announcement

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

  • Help with adjusting the range of a scatterplot

    Hey guys! I want to adjust the range of my scatterplot. I have some large outliers that I still want to include in my estimates, just not in the figure.

    Code:
    twoway (scatter bf078 year if treat == 1 & lowincomelimit == 1, msize(vsmall) mcolor(red)) (scatter bf078 year if treat == 1 & lowincomelimit == 0, msize(vsmall) mcolor(blue)) (qfitci bf078 year if year < 2011 & treat == 1 & lowincomelimit == 1, sort lcolor(black)) (qfitci bf078 year if year > 2011 & treat == 1 & lowincomelimit == 1, sort lcolor(black)) (qfitci bf078 year if year < 2011 & treat == 1 & lowincomelimit == 0, sort lcolor (green)) (qfitci bf078 year if year > 2011 & treat == 1 & lowincomelimit == 0, sort lcolor(green)), xline(2011) ytitle("bf078")

    Graph:

  • #2
    Same way you are restricting the sample using the -if- qualifier:

    twoway (scatter bf078 year if treat == 1 & lowincomelimit == 1, msize(vsmall) ...
    Code:
    twoway (scatter bf078 year if treat == 1 & lowincomelimit == 1 & bf078<=X, msize(vsmall)
    where "X" is some specified limit.
    Last edited by Andrew Musau; 05 May 2023, 04:23.

    Comment


    • #3
      Thank you Andrew Musau. However, I do not want to restrict my sample. How can I have the full sample and zoom in on the graph at the same time?

      Comment


      • #4
        I don't think this is going to work as you wish. Calling up qfitci without restricting the range is going to give you a graph that is for all the data; while calling up qfitci with restricting the range will not just restrict the graph, it will restrict the estimation sample too. You can't have it both ways at once

        I think -- to get what you want -- you would need to generate the confidence intervals outside of graph and then plot within your desired interval.

        The whole idea doesn't make much statistical sense to me, frankly. There should be better ways to show the outliers and model with them; or if it is defensible to set aside the outliers, period.

        What does bf078 look like any way? Can you show the results of

        Code:
        quantile bf078 if treatment == 1
        please?

        Comment


        • #5
          "Zooming in" is restricting data points. Stata will not allow you to truncate data, e.g.,

          Code:
          scatter y x, ysc(range(y1 y2))
          [.] The limits will be ignored if they imply truncating the data. On a related note, see this new community-contributed command on creating inset plots if you wish to show both the scatter plot created from the full sample and from the truncated sample: https://www.statalist.org/forums/for...lable-from-ssc

          Note: Crossed with #4.
          Last edited by Andrew Musau; 05 May 2023, 05:08.

          Comment


          • #6
            For my analysis, I am using a regression discontinuity design to show differences before and after different cutoffs for the variable bf078. My graph looks like this:

            Bf078 is a variable that measures average monthly household consumption in a year. When limiting the sample: bf078 < 5000, I get a graph that shows my data in a better way. However, does this not bias my results?

            The option for ysc(range()) does not seem to work for me. This changes my y-axis but keeps the data the same.

            Comment


            • #7
              Sorry, this is the graph:
              Attached Files

              Comment


              • #8
                It's your project but a plot like that says to me "work on log scale".

                Comment


                • #9
                  Thanks! I will try that

                  Comment

                  Working...
                  X