Announcement

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

  • Quantile plots

    Hi all,
    I have run a simulation model calculating an outcome Y in 100000 iterations. I'd like to plot the proportion of iterations (y axis) where Y is less than a particular threshold as a function of values of that threshold (x axis). More specifically, Y is a cost and X is a willingness to pay (WTP) threshold. I'd like to plot the proportion of iterations where a stakeholder would deem the cost "affordable" as a function of increasing WTP thresholds. I can't get the plot quite right. I've tried

    qqplot iteration Y

    but it gives me the raw iteration number on the y axis instead of the proportion (or percent). I tried scaling the iteration number by dividing by 1000, but that flattens the displayed curve and makes it unreadable. Also, I don't need the reference line because I'm not using the graph for diagnostics.

    Any suggestions on a better way to go about this, perhaps by manipulating the data and using a standard twoway graph?
    Thanks in advance,
    Doug

  • #2
    Code:
    quantile Y
    may be what you seek.

    Comment


    • #3
      Thanks, Nick. That does it EXCEPT, it has WTP threshold on the y axis and proportion affordable at that threshold on the x axis. I'd like the axes reversed - do you know if that's possible? Also, do you know if one can suppress the reference line in quantile (other than by manually editing the plot post hoc)?
      Best,
      Doug

      Comment


      • #4
        So you want an empirical cumulative distribution function plot (many shorter names are in use):

        Code:
        search distplot,  sj

        Comment


        • #5
          Perfect, that was exactly what I needed. Thanks!

          Comment


          • #6
            I spoke too soon. "distplot" gets me close, but for presentation, I don't actually care about the entire cumulative distribution function, I just want to present the CDF in the range that might reasonably be considered affordable. For example, in the auto data, I might like to plot the distribution of prices up to 10000. The plot would show the line intercepting the right-hand y axis at ~86%. Anything above 10000 is "unreasonably expensive" and not of interest. I tried altering the range, but Stata will not plot an x range smaller than the actual range of x values. If I truncate the plot using "if price<10000", that incorrectly restricts the range of values used in calculating the CDF. Any additional thoughts? Again, many thanks. -Doug

            Comment


            • #7
              "incorrectly" is your point of view, not mine as programmer of distplot (don't blame Stata here). My take is standard Stata thinking: if you select observations, then the observations not selected do not enter the calculation.

              You have another interpretation, which is to calculate the entire function, but only show part of it.

              The bottom line of distplot's help is

              Help: [G] graph, [R] cumul, [R] quantile, qplot (if installed), mylabels (if installed)
              and the key here is cumul. Here is some technique.


              Code:
              sysuse auto, clear
              cumul price, gen(F)
              line F price if price < 10000, sort


              Comment


              • #8
                I'm not blaming Stata or disparaging distplot, just trying to figure out the best solution to my own problem which led to trying to fit my round peg into some square holes. cumul was the function I needed all along -- thanks for steering me there!

                Comment


                • #9
                  Indeed. Equally I don't accept as criticism of distplot that it doesn't work in this context in the way you want.

                  cumul is strictly a command, not a function.

                  Pleased you got there....

                  Comment

                  Working...
                  X