# Using phi as a measure of correlation for categorical analysis

I'm working on a data analysis project where I've been asked to measure the association between specific values of categorical variables, and I wanted to make sure my thinking was correct. So for example, I have the U.S. State where each user lives and then the number of products they've purchased from a specific Brand. I built contingency tables that looks like this:

State 1 State 2 State 3 ... State 50
Brand 1 number of orders from Brand 1 by users in State 1 ... ... ... ...
Brand 2 ... ... ...
Brand 3 ... ... ...
... ... ... ...
Brand 60 ... ... ... ... number of orders from Brand 60 by users in State 50

I am looking for a measure of association between say Brand 3 and State 12. To calculate this, I reduced the data to a 2x2 table of the form:

State 12 Not State 12
Brand 3 value of the cell Brand 3 State 12 sum of all other values in the row "Brand 3"
Not Brand 3 sum of all other values in the column "State 12" sum of all remaining values

I ran the entire table through some code that created 2x2 tables for every possible pairing and then calculated a phi value for each. So that I ended up with a table that looks like this:

State 1 State 2 State 3 ... State 50
Brand 1 phi from table State 1, Not State 1 against Brand 1, Not Brand 1 ... ... ... ...
Brand 2 ... ... ...
Brand 3 ... ... ...
... ... ... ...
Brand 60 ... ... ... ... phi from table State 50, Not State 50 against Brand 60, Not Brand 60

My first question is, are these phi values statistically valid measures of association between specific brands and states? I calculated Cramer's V for the full table and got a reasonably strong association, but the individual phi values were all between -0.2 and +0.2, most of them very close to 0. I also tried running the same process reducing the states to regions and using only the top 20 or so brands, but no stronger phis appeared. I just want to make sure my thinking is correct before I say there's no correlations here strong enough to act upon.

The second question is about the next project I'm working on, which is correlating medical Specialty to Brand. In the case of states, there was only one state for each user, but users can and often do have multiple Specialties, so am I able to use the same process? I have an additional column in these contingency tables that gives the total number of orders from a Brand (not equal to the sum of orders in the Brand rows because of the overlapping specialties).

Specialty 1 Specialty 2 Specialty 3 ... Specialty 11 Totals
Brand 1 number of orders from Brand 1 by users with Specialty 1 ... ... ... ... Total orders from Brand 1 ( =/= sum of row "Brand 1")
Brand 2 ... ... ... Total orders from Brand 2 ( =/= sum of row "Brand 2")
Brand 3 ... ... ... ...
... ... ... ... ...
Brand 20 ... ... ... ... number of orders from Brand 20 by users with Specialty 11 Total orders from Brand 20 ( =/= sum of row "Brand 20")
Totals sum of column "Specialty 1" sum of column "Specialty 2" ... ... ... sum of column "Totals" ( =/= sum of row "Totals")

I am assuming to reduce these to 2x2 tables, instead of summing the rows, I would do this:

Specialty 12 Not Specialty 12
Brand 3 value of the cell Brand 3 Specialty 12 value of Brand 3 Total MINUS value of Brand 3 Specialty 12
Not Brand 3 sum of all other values in the column "Specialty 12" value of the cell Totals Totals MINUS the other 3 calculated cells

But this feels wrong to me because the column totals still overlap each other. What am I missing here? Is any of this valid or is this just bad math?

EDIT: To clarify the purpose of this project, I am looking for

1. meaningful correlations between specialty and brand that can be passed on to a marketing team in order to set up promotions where users with certain specialties are offered their specialty's preferred brands

2. generally correlated brands and specialties for reference after a more robust product recommendation feature is built out. The exact way this will be used is a little unclear to me, but I believe it's basically just for comparison once there is a more complete clustering algorithm in place. As in, we look at the groups that just clustering products based on purchase patterns has given us and we see that oh a bunch of Brand 5 is bought by a bunch of users with this Specialty 3 and then we look back at the project I am doing and confirm, yep, we had noticed a correlation there. I think that's the idea. The marketing thing is the more immediate concern however.

• What do you need this measure of association for? What do you hope to learn from it / what do you intend to do with it once you have it? Unless this is a textbook assignment where the point is to show you got a specific number, you ultimately want something else from it. The issue is what will best get you to that thing. Jun 17, 2021 at 17:17
• Thanks for your response! I am trying to analyze relationships for the purpose of 1) marketing and 2) as reference for an in development product recommendation feature. I'll put an edit in the post shortly Jun 17, 2021 at 17:50
• Fair enough, but how would this number help you with marketing, eg? How would you use the reference in the future to recommend products? Jun 17, 2021 at 17:53
• I think the intent with marketing is that if there are any unusually high correlations between specific specialties and specific brands, they will focus marketing those brands to those specialties. As far as using it as a reference for other product recommendation feature, I'm honestly a little confused about that myself. I've asked if I could just do some product clustering based on things frequently bought together or bought by the same users, but my supervisor has insisted upon doing this analysis first. I think it's just for reference? To see if the clusters match up with specialty. Jun 17, 2021 at 18:28