Announcement

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

  • aaplot updated on SSC

    Thanks as usual to Kit Baum, the program aaplot has been updated in the package of the same name on SSC. The update fixes a minor bug that, it seems, bit me alone.

    The program was first announced in http://www.stata.com/statalist/archi.../msg01131.html

    I repeat here the essence of that announcement and give below a few examples, as was not possible in 2011 when the forum was an email-based list without attachments.

    The aa in aaplot can be thought of as "automatic annotation", namely that this plot is for showing

    a scatter plot with linear and/or quadratic fit, automatically annotated

    the annotation being, by default, model equations (with coefficients moderately rounded) and a display of R-square, sample size n and root mean square error. To get a formal statement,

    Code:
    . ssc type aaplot.sthlp
    To download, use ssc or adoupdate, as appropriate.

    Since Stata 8, there have been various official commands, scatter, twoway lfit, twoway qfit, two or three of which are commonly combined on the fly or in programs. aaplot is just a convenience command putting together two or three of those official commands. Some users with very long memories may recall a sparl program, still on SSC, last revised in 2000, which requires Stata 6 and up, and still works, but is confined to the old graphics.

    While hoping that aaplot might prove useful -- for example, in teaching or for initial explorations -- it
    is at best indicative, and certainly not definitive. Some tastes might run to showing (for example) standard errors, t statistics and P-values instead of, or in addition to, the results shown. Users so inclined should feel free to clone aaplot and should feel compelled to use their own different program name. (Totally out of the question as far as I am concerned is starring * ** *** equations as if they were hotels,restaurants or movies).

    Stata 11 is required, but enterprising Stata users confined (say by financial exigency) to one of Stata 10,9 or 8 should find that a few minutes' work should be enough to make something very similar work with their Stata.

    Here are some simple examples. Suppose we fire up the auto data and realise that curvature in the relation between mpg and weight implies some kind of transformation. A reciprocal sounds a good idea. In creating a new variable, we see as usual that a variable label would yield a better axis title. There is always some kind of dopey detail to fix: here our token is that the default format for RMSE is just the same as the variable created. We could certainly survive with fewer decimal places; indeed the number here is probably excessive still. The graphs below are the first and third created by this sequence.

    Code:
    sysuse auto, clear  
    aaplot mpg weight  
    gen gpm = 1000/mpg  
    aaplot gpm weight  
    label var gpm "Gallons / 1000 miles"  
    aaplot gpm weight, rmseformat(%5.4f) both
    Click image for larger version

Name:	aaplot1.png
Views:	1
Size:	10.8 KB
ID:	1319290

    Click image for larger version

Name:	aaplot2.png
Views:	1
Size:	13.4 KB
ID:	1319289

    Last edited by Nick Cox; 07 Dec 2015, 09:01.

  • #2
    Thanks for this. What if I want position marker? That is, the variables represented on the X-axis, say, year be represented instead of the scatter plots.

    Comment


    • #3
      Sorry, but I don't understand the question. Please give an example of what you want but don't get.

      Comment


      • #4
        Thanks. Something like the attached file in addition to a regression line

        Last edited by Zuhumnan Dapel; 17 Feb 2016, 21:11.

        Comment


        • #5
          Thanks for the example, but please don't post photo attachments:

          ​http://www.statalist.org/forums/help#stata

          http://www.statalist.org/forums/foru...ood-others-not

          The solution is nothing specifically to do with aaplot (SSC). It is documented scatter technique.

          Code:
          help marker label options
          
          webuse grunfeld
          scatter invest kstock if company == 1, mlabel(year)

          Comment


          • #6
            Thanks. I've got this already. What if I want the regression line and the estimates, just like the figures in post #1 to show?

            Comment


            • #7
              A marker label option is perfectly compatible with aaplot. It's documented that it allows


              scatter_options are any options allowed for scatter excluding by().
              These include the options for titling the graph (see title_options),
              for tuning the display of data points and for saving the graph to
              disk (see saving_option).


              Why not try it? (The graph might be horribly crowded, but that's your choice.)

              Comment


              • #8
                Worked out exactly, thanks!

                Comment


                • #9
                  Hi! I have been using this great program - aaplot - and I love it. Is there a way to hide one of the notation boxes? Specifically, I would need to hide the RMSE. I can't seem to figure out the syntax to do so. (please keep in mind that I am somewhat of a novice!)

                  Thank you so much.

                  Comment


                  • #10
                    RMSE is shown in a note together with the sample size; this is mentioned in the help. So, in this example and others blanking out the note() would work to remove that.

                    Code:
                    sysuse auto, clear
                    aaplot mpg weight 
                    aaplot mog weight, note("")
                    If you wanted the note to contain the sample size but not the RMSE, you would need to go

                    Code:
                    aaplot gpm weight, note("{it:n} = 74")
                    Naturally your sample size is probably different and you may prefer some other way of indicating sample size.

                    Comment


                    • #11
                      Ok so I would manually enter the sample size, in your second example, correct?

                      Comment


                      • #12
                        The way I did it was to run aaplot once and note the sample size. But if you never (hardly ever) want to see RMSE you should clone the program and edit it under a different name to do what you want.

                        Code:
                        gravelplot
                        and

                        Code:
                        sabrinaplot
                        are both available names.

                        Comment


                        • #13
                          Right! Okay this sounds great. Thank you very much for your help.

                          Comment


                          • #14
                            Thanks again to Kit Baum, aaplot has been updated on SSC to support display of minus characters using SMCL, rather than hyphens pretending to be minus signs.

                            Comment

                            Working...
                            X