Announcement

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

  • spechist updated on SSC

    Thanks to Kit Baum, as usual, spechist has been updated on SSC. If you have it already installed you can updated it by typing adoupdate, update, and if you don't have it already installed (mmmmm what are you waiting for? ) you can install it with the usual ssc install spechist.

    spechist produces one or more histograms with the specified methods for calculating either the bin width, or the number of bins of the histogram. You can pass in one or more methods for the calculation of the bins. If you pass more than one, it will combine the histograms in one graph.

    This new version gives the flexibility to choose where you want to display the method use in the individual graphs, or to not display it at all. It also allows for the use of start() as an option for the individual histograms.

    If you have any comments or suggestions, shoot me an email. If you know of any other methods for calculating either the number of bins, or the bin width, than those included there, please send the reference to me, and I will see if I can include them as more options in future versions.
    Alfonso Sanchez-Penalver

  • #2
    Hi Alfonso, this is a great command, really needed for my work! Quick question: how do i export the results i.e. generate new variables so that i can see which observation fall into the different bins!

    thanks in advance for your help!

    Best regards,

    Stelios

    Comment


    • #3
      Hi Stelios, this is a great question, and the short answer is I don't know because the command histogram, which is the one that spechist uses to create each graph, doesn't store these things. But you have given me something to think about to see how I could actually store these things in my command myself. Maybe something to update in a later version.
      Alfonso Sanchez-Penalver

      Comment


      • #4
        Alfonso,

        histogram calls twoway__histogram_gen.ado, which is a sort of pre-processor before it calls twoway histotgram, so you might look at that for ideas on how Stata generates bins. You can even call it yourself using the return, display, and gen() options to see what it is doing.

        The upshot of it (vis-a-vis the request by Stelios) seems to be the following formula for generating a categorical variable that indicates which values map to which bins:
        Code:
            gen `midbin' = floor((`v'-`min')/`h') if `touse'
        where v is the variable name, min is the minimum for that variable and h is the bin width.

        Hope this helps.

        Regards,
        Joe

        P.S. Thanks for the acknowledgement in the spechist documentation; I had forgotten about that conversation.

        Comment


        • #5
          Hi Joe, I will definitely look into it when I have time to revisit the program, i.e. when I have some time not preparing classes, listening to students, getting papers ready... lol. I think it is a great idea to be able to return a list of the actual bins used for each of the graphs. I do wonder why histogram doesn't do it. Not only for Stelios request but I'm sure it would become handy for other purposes.

          You're welcome, you did help me out of a pickle!!! :D
          Alfonso Sanchez-Penalver

          Comment


          • #6
            So I went ahead and changed the program to store different information into r(). The bin boundaries I'm storing in matrices, so I guess you would have to convert them into lists to create the dummies, or you can do them in a loop. I used the twoway__histogram_gen command as Joe suggested, and getting the minimum, the width and the number of bins, I looped to generate the rest of the boundaries, with a simple addition in the loop (lower bound plus width). Stelios if you give me your full name I'll credit you for the specific functionality. Joe, you will always be credited of course, you keep pointing me in the right direction!!! I'll wait to see if Stelios gets back with his name a couple of days, and submit the update then.

            Thanks you both!!!
            Last edited by Alfonso Sánchez-Peñalver; 29 Jul 2014, 10:21. Reason: formatting
            Alfonso Sanchez-Penalver

            Comment

            Working...
            X