Announcement

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

  • How to calculate Cramer's v by group, or using by() command

    Hello,
    I am trying to calculate Cramer's V statistic for the same variable for different groups. For example, I am trying to calculate the effect size of height between women and men. Thus, the variable of interest is one variable (height) by two groups (women v men). I have tried to use the by() command, but I receive the "option by() not allowed" error. I have tried variations of the following command that have given me an error:

    tabulate height, by(gender) V

    Does anyone have experience on how to include the by() command when calculating the Cramer's V statistic? Thank you!

  • #2
    And just for more information, the height variable is categorical.

    Comment


    • #3
      You won't get that out of a one-way tabulation, or even repeated one-way tabulations. It's only possible with a two-way tabulation.

      Note that even as a measure of association, this one ignores the ordering, important here for rep78 and important for your height variable.

      Code:
      . sysuse auto , clear
      (1978 Automobile Data)
      
      . tab fore rep78, V
      
                 |                   Repair Record 1978
        Car type |         1          2          3          4          5 |     Total
      -----------+-------------------------------------------------------+----------
        Domestic |         2          8         27          9          2 |        48
         Foreign |         0          0          3          9          9 |        21
      -----------+-------------------------------------------------------+----------
           Total |         2          8         30         18         11 |        69
      
                     Cramér's V =   0.6286
      Note that by() is an option, not a command.

      Comment


      • #4
        Thank you so much for your response. It works perfectly!

        Comment

        Working...
        X