Announcement

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

  • Kruskal Wallis Test with Frequency Tables

    Does anyone know the code for doing a kruskal wallis test with a frequency table (i.e., one column is the outcome, one column is the outcome score, and the last column is the frequency of people who chose the outcome score). Thank you!

  • #2
    Lucy:
    welcome to this forum.
    I'm not clear with what you're after.
    Please read the FAQ on how to post more effectively. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      I meant, I am trying to do a Kruskal Wallis test for my frequency table. However, Stata won't let me specify [fweight = frequency]. Does anyone know how I am able to specify fweight for the Kruskal Wallis test on Stata?

      Comment


      • #4
        I would temporarily expand the dataset using your frequency variable. Here's a silly example.

        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . set seed 2803
        
        . gen freq = runiformint(10, 50)
        
        . preserve
        
        . expand freq
        (2,129 observations created)
        
        . kwallis mpg, by(rep78)
        
        Kruskal-Wallis equality-of-populations rank test
        
          +-------------------------+
          | rep78 | Obs |  Rank Sum |
          |-------+-----+-----------|
          |     1 |  54 |  67265.00 |
          |     2 | 243 | 170790.00 |
          |     3 | 893 | 777200.50 |
          |     4 | 553 | 654902.00 |
          |     5 | 284 | 385220.50 |
          +-------------------------+
        
        chi-squared =   274.954 with 4 d.f.
        probability =     0.0001
        
        chi-squared with ties =   276.728 with 4 d.f.
        probability =     0.0001
        
        . restore

        Comment


        • #5
          Oh yay, that worked. Thank you so much!

          Comment


          • #6
            Good. Please close out your cross-post at https://www.reddit.com/r/stata/comme...r_the_kruskal/

            Comment

            Working...
            X