Announcement

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

  • Histograms from ttest mean comparisons

    Hello,

    I'd like to present ttest mean comparisons with histograms instead of the standard table given by the command.

    Basically, I'm thinking about something like the graph in the link where, for multiple samples, I could easily show the significant differences and p-values.

    To be more precise, let's say I want to make a two sample using groups (lang on one hand, public on the other hand) mean-comparison of the variable gtrust and to present the results with a chart similar to the one in the link.

    Some people told me there exists such a command but I cannot find it. Otherwise, do you have any idea on how to produce such a chart?

    Thank you.

    [CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte gtrust float(lang public)
    6 1 0
    3 1 0
    5 1 0
    . 1 0
    4 1 0
    3 1 0
    6 1 1
    . 1 0
    8 1 1
    4 1 1
    . 1 0
    6 1 1
    4 1 0

  • #2
    It's possible to get the four means and six mean comparison from -regress- and a couple post-estimation commands. Here is an example. I had to use another sample data set because "lang" in your sample does not vary.

    Code:
    clear
    set obs 100
    gen gtrust   = floor(runiform()*6)+1
    gen lang    = (runiform() > 0.5)
    gen public  = (runiform() > 0.5)
    
    * Comparison of the four means:
    regress gtrust i.lang##i.public
    * Getting the four means and their 95%CI
    margins lang#public
    * Getting the six pair-wise comparison with their p-values
    pwcompare lang#public, eff
    As for how to make that kind of graph, I am not sure. But this thread may help: https://www.statalist.org/forums/for...l-significance

    Comment


    • #3
      Thank you Ken, it was helpful.

      Regarding the graph, after exploring the link you sent, I think it is easier to use an external software, such as Inkscape.

      Comment


      • #4
        The graph linked to in #1 for software called OriginLab (which I know nothing about) is there described as a Grouped Column Chart Showing Significant Differences

        and many people would be happy to call it a bar chart. It is not a histogram, which means a bar chart showing a frequency distribution as a series of bars.

        Whatever the name, the form just shows group medians as bars with other bars showing IQRs.

        The example is highly suspect, as it appears to show the results of several pairwise tests of some kind for a design with 3 samples and 3 periods. Whether these are post hoc tests and how far they form the best analysis is an open question.

        Let's leave that there. #1 clearly shows interest in t-tests comparing different means.

        Plots showing means as bars and say standard errors as further very thin bars are still widely used (in my experience, especially in some biological sciences) but also widely deprecated. The informal names detonator, dynamite and plunger plot are attached to much that explains why they are a really bad idea, e.g.

        https://biostat.app.vumc.org/wiki/pu...de/Poster3.pdf

        https://warwick.ac.uk/fac/sci/wdsi/e...es/plunger.pdf

        https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3087125/

        and so on, and so on.

        The main principle is simple: Show enough about the data -- preferably the data -- so that readers can see for themselves (a) whether (in this case) the t test is a good idea beyond the fact that it yields results appealing to the researcher and (b) how far the analysis might be problematic.

        In Stata beyond Ken Chui's excellent suggestions, you could make a good start with twoway bar and twoway rcap but you'd need to do extra things to get the decoration of P-values and the like. As I can't encourage this kind of plot, I won't say more.

        But in #1 gtrust is exemplified as having small integer values. t tests are forgiving, but if I were reviewing this research I would want to see histograms (correct sense) for your data.
        Last edited by Nick Cox; 04 Dec 2021, 05:20.

        Comment

        Working...
        X