Announcement

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

  • Asking about a data set for demonstrating the assumption of identical shape of distribution when using Kruskal Wallis test

    Dear all,

    I would like to demonstrate the assumption mentioned above by a real data set, by which I mean a data set with a same median between groups, but p value after testing is less than 0.05 when using Kruskal Wallis test. It's simply because the distribution of groups are not identical. So if you have a data set like this, would you mind sharing it with me, please?

    Thank you so much in advance

  • #2
    Please see whether this is what you wish:


    Code:
    . use http://www.stata-press.com/data/r14/census
    (1980 Census data by state)
    
    . kwallis medage, by(region)
    
    Kruskal-Wallis equality-of-populations rank test
    
      +--------------------------+
      | region  | Obs | Rank Sum |
      |---------+-----+----------|
      | NE      |   9 |   376.50 |
      | N Cntrl |  12 |   294.00 |
      | South   |  16 |   398.00 |
      | West    |  13 |   206.50 |
      +--------------------------+
     
    chi-squared =    17.041 with 3 d.f.
    probability =     0.0007
    
    chi-squared with ties =    17.062 with 3 d.f.
    probability =     0.0007
    
     
    . dotplot medage, over(region) median center

    Below, the graph with the median in red.

    Click image for larger version

Name:	Graph_dot_png.png
Views:	1
Size:	11.3 KB
ID:	1377559
    Best regards,

    Marcos

    Comment


    • #3
      Dear Marcos,

      Thank you so much for your response. However, what I would want to have is two real data sets (or simulation data sets). One for demonstrating that two or more groups with same median value could result in a statistical significant p value (p-value <0.05) when using the Kruskal Wallis test. In the case, it's simply because three groups have different distribution shapes. As you know, the Kruskal Wallis test only test the difference in median between groups if those groups have same shape of distribution, but shift in location. When three grouups have different shape of distributions, Kruskal Wallis tests the mean rank between groups, so p-value shows us the difference in mean rank, not median between groups.
      I also give you a link for more detail.
      https://statistics.laerd.com/stata-t...sing-stata.php

      Thank you again, Marcos!

      Comment


      • #4
        Dear Marcos,

        Can I simulate three groups with same shape of distribution and different in location (like the example I show below, on page #6), but all three groups are non-normal distributed.
        http://www.stata.com/manuals13/rdotplot.pdf

        Thank you so much!

        Comment


        • #5
          Thong Nguyen I believe the dot plot performs better than histogram in the situation mentioned in #3. By the way, it is common ground that, shall we change the bin width, the "shape" of the histogram may change as well. Actually, I believe the dot plot I provided gives a representation of the very same fact you wished to have in #1. i.e, different patterns of distribution according to the level of the group variable, with the advantage of being, you know, a dot plot.

          Best regards,

          Marcos

          Comment


          • #6
            Dear Marcos,
            Please could you help me to simulate data for three groups which has same shape of distribution and different median as the diagram in the link I gave you in thread#3? Thank you so much for your help!

            Comment


            • #7
              About simulations of skewed variables in Stata, I wish to add three comments:

              Clyde Schechter, in this thread, recommended the reading of this SJ article, written by Nick Cox. Thought-provoking, really.

              You may fiddle with the commands suggested in this thread , shared in a different forum.

              There is the user-written program, SKNOR, "Stata module to generate a sample from a normal or skewed (skew-normal) distribution, as defined by the user", written by Evangelos Kontopantelis.

              I confess I haven't used it so far (maybe I'll install it and check it out), hence I cannot share with you more information than just mentioning the program. Hopefully it will be useful for you.
              Last edited by Marcos Almeida; 09 Mar 2017, 08:26.
              Best regards,

              Marcos

              Comment


              • #8
                Dear Marcos,

                Thank you for your response and your recommendations. I made it works using -sknor- package. Thank you so much, Marcos. Here is the code I used
                Code:
                clear all
                sknor 500 123 5 1 -0.5 3
                gen y = skewnormal + 2
                gen z = y + 3
                ren skewnormal x1
                ren y x2
                ren z x3
                gen id = _n
                sort id
                
                reshape long x, i(id) j(group)
                
                tabstat x, s(n mean sd p50 p25 p75 min max) format(%9.1f) by(group)
                twoway histogram x if group == 1, ///
                             fcolor(none) lcolor(green) xline(5.1, lp(dash) lw(medthick) lc(green)) || ///
                        histogram x if group == 2, ///
                             fcolor(none) lcolor(blue) xline(7.1, lp(dash) lw(medthick)) lc(blue) || ///
                        hist x if group == 3, ///
                             fcolor(none) lcolor(red*.3) xline(10.1, lp(dash) lw(medthick)) lc(red) ///
                    legend(ring(0) pos(11) cols(1) ///
                    order(1 "group 1" 2 "group 2" 3 "group 3"))
                kwallis x, by(group)

                Comment


                • #9
                  Hello Thong,

                  Thank you for sharing the command and considering your query reached its closure.
                  Best regards,

                  Marcos

                  Comment

                  Working...
                  X