Announcement

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

  • generate histograms with descriptive statistics

    Hi,

    I got a question about the histogram command in STATA which I cant solve by googleing it or reading the STATA help article: is it possible to create histograms where there is a box inside the histogram with statistics about the variable of interest like mean, median, st. dev., skewness, and kurtosis and if there is such an option, how would the code look like?

    Thank you very much!

    Cheers,

    Kurt

  • Kurt Wichtelsacker
    replied
    It works fine for me so I wouldnt change it...but I problems will accour I will come back to your solution thanks!

    Leave a comment:


  • wbuchanan
    replied
    You may want to consider gr combine as an option to generate the combined .EPS image. I've built out some info graphics before using it and it might help you if you need to start debugging changes across the two languages.

    Leave a comment:


  • Kurt Wichtelsacker
    replied
    No I am doing that in LaTeX afterwards, so I use STATA to generate the graphs, then compile them to eps and then put them into a floatfigure in LaTeX...

    Leave a comment:


  • wbuchanan
    replied
    Are you using the graph combine command to put them together on a single page? It has options that deal with scaling the figures which may help the aesthetics of the page overall.

    Leave a comment:


  • Kurt Wichtelsacker
    replied
    Thank you very much that worked out very well!! It doesnt look that awfully, but because I will stack 12 graphs on one a4 page, it gets pretty small...

    But you saved my whole day of STATA work

    Leave a comment:


  • wbuchanan
    replied
    I embedded an option that does something analogous to this in a new program I've been working on: https://github.com/wbuchanan/eda.

    There is an option in the main program to include reference lines for Tukey's five number summary and it prints mean, sd, and optionally the five number summary as a caption. If that suits your needs you can get all of the histograms you want using eda, but you'll need to turn off the other graphs.

    Leave a comment:


  • Clyde Schechter
    replied
    No, you can't embed a command inside the -text()- option. But you can run those commands before you plot the graph, save the relevant statistics as local macros, and then use those in the -text()- option. For example:

    Code:
    summ monun2 if gdum == 0, detail
    local mean = r(mean)
    local median = r(p50)
    local sd = r(sd)
    // etc.
    twoway hist monun2 if gdum==0, ///
    frac name(psmonun0a, replace) ///
    plotregion(fcolor(white)) graphregion(fcolor(white)) bcolor(blue*0.7) ///
    text( 1 0.6 {"mean = `mean', median = `median', sd = `sd'"} , ///
    place(se) box just(left) margin(l+4 t+1 b+1) width(XX) )
    For what it's worth, I think sticking 5 different statistics in a text box on a graph is going to look awfully cluttered, and probably hard to read. Would it be helpful to put them in a -note()- option instead?

    Leave a comment:


  • Kurt Wichtelsacker
    replied
    Thank you very much, that helped. But how can I actually run a command in the text option? As far as I read from the STATA help, only text is allowed. Not something like a sum var if ..., options.... But thats what I would need. Am I doing something wrong or is there another syntax for this?

    my code:
    twoway hist monun2 if gdum==0, ///
    frac name(psmonun0a, replace) ///
    plotregion(fcolor(white)) graphregion(fcolor(white)) bcolor(blue*0.7) ///
    text( 1 0.6 {here there should be a command for writing sum statistics into the text box} , place(se) box just(left) margin(l+4 t+1 b+1) width(XX) )

    Thank you!


    Leave a comment:


  • Dave Airey
    replied
    See help added_text_options.

    Leave a comment:

Working...
X