3
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Jun 17, 2021 at 17:17
  • $\begingroup$ 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 $\endgroup$
    – Gabriella
    Commented Jun 17, 2021 at 17:50
  • 1
    $\begingroup$ Fair enough, but how would this number help you with marketing, eg? How would you use the reference in the future to recommend products? $\endgroup$ Commented Jun 17, 2021 at 17:53
  • $\begingroup$ 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. $\endgroup$
    – Gabriella
    Commented Jun 17, 2021 at 18:28

1 Answer 1

2
$\begingroup$

I don't think that's the best way to go. This seems more exploratory in nature. With really large contingency tables, where you can't just look at the numbers and see the pattern, I would run a correspondence analysis and look at the plot. A correspondence analysis looks at how similar the rows are to each other, and how similar the columns are to each other, and then plots points for each row and column such that points for rows (columns) that are similar are close, and those that are dissimilar are far. In addition, a row point will be closer to a column point if more of the counts in that row are in that column. I demonstrate a correspondence analysis here: Which is the best visualization for contingency tables?

$\endgroup$
3
  • $\begingroup$ I think this is more what I have been looking for. Thanks so much for your help with this! Can I ask if you have any advice on running correspondence analysis on a contingency table with overlapping columns, per the specialty tables where a user can have more than one specialty? $\endgroup$
    – Gabriella
    Commented Jun 18, 2021 at 19:41
  • 1
    $\begingroup$ You're welcome, @Gabriella. $\endgroup$ Commented Jun 19, 2021 at 1:18
  • 1
    $\begingroup$ Correspondence analysis is a descriptive / exploratory technique. There isn't really an issue of p-values being invalid because the data are non-independent. If you want, you could try it a couple different ways by sometimes putting a person only in 1 category, & sometimes only in another, but I doubt it will make much difference. $\endgroup$ Commented Jun 19, 2021 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.