Announcement

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

  • Cramer V, more than 2 variables, table

    We can calculate the Cramer's for each single variable combination by "tabulate v1 v2, V". But is it possible to calculate contingency table with Cramer's V for 13 different variables for example like correlation table? In order avoid using many commands manually.

  • #2
    I'm thinking you want to calculate Cramer's V between all possible pairs of variables in a list, which can be produced by creating your variable list and looping over all distinct pairs, as follows:
    Code:
    local vlist YourV1 YourV2 ... YourV13
    local nvar: word count `vlist'
    mat V = J(`nvar', `nvar', .)
    forval i = 1/`=`nvar' -1' {
       forval j = `=`i' + 1'/`nvar' {
         local v1 = word("`vlist''", `i')   
         local v2 = word("`vlist'", `j')   
         tabulate `v1' `v2', V
         mat V[`i', `j'] = r(CramersV)
         mat V[`j', `i'] = r(CramersV)
       }
    }   
    mat list V
    This being said, I would not recommend Cramer's V as a measure of association. It's not a popular measure, so I'd encourage you to use some measure that's currently widely used in your field of research.

    Comment


    • #3
      Mike Lacy Thanks for your reply. There is a mix of categorical (ordinal &nominal) and binary variables in dataset. All the variables as coded 0/1/3 etc. Pearson correlation/pairwise, spearman correlations are used commonly in health sciences. I ended up using spearman as it can be used with non-linear distribution. I wanted to try Cramer V, some articles mentioned using it with categorical variables. But agree did not see it's much use in recent research studies.

      Comment

      Working...
      X