0
$\begingroup$

I have a data set of users. that looks something like this.

user_id appetizer main_meal
185 30 120
142 8 56
34 0 200
etc. etc. ..

there are other columns but I don't believe it's relevant for my question. Each row is unique in the sense that it corresponds to one customer and the customer does not appear more than once in the data set. This data set was aggregated from a set of transactions that took place from 2020 to 2021. I want to see if there is a correlation between appetizer and main_meal. So I use the function cor in R to calculate the correlation between them. It is around 0.6. I also made a scatter plot and indeed see that there seems to be a linear trend. I want to conclude that the amount of appetizer is indeed correlated with main_meal. However, I then thought well maybe there is the appearance of correlation but in reality, there is another factor that contributes to this trend. I think this because if I look at a daily period instead of a year period there is no correlation in the number of appetizers and main meals.

What I would like to see is that more appetizers usually means more main meals however this is not the case in a daily period or there seems to be no linear relationship at least.

Can someone explain why there is no correlation for a daily period but if I take the sum totals for a yearly period for each user there is a correlation between the two variables.

Edit Just as an example when looking at the first row we see that there is a customer with the user_id 185. For the year period (2020-2021) this customer had ordered a total of 30 appetizers and 120 main meals. There are many branches of this restaurant so the orders could have taken place in any of these branches. The numbers are indeed a count. There are certain meals that are classified as main meals on the menu and some are classified as appetizers.

$\endgroup$
8
  • 4
    $\begingroup$ Is the appetizer number a quantity, or does it correspond to a particular item like mozzarella sticks? Ditto for the main meal. $\endgroup$
    – Dave
    Commented Aug 10, 2021 at 13:46
  • $\begingroup$ Have you uncovered that people who order a lot from your service order a lot of both? It sounds like that, but Dave’s question will clarify this. $\endgroup$ Commented Aug 10, 2021 at 13:51
  • $\begingroup$ It might be important to understand what your data mean. Are you saying these are counts? If so, what does a count of "200" for "main_meal" actually measure? $\endgroup$
    – whuber
    Commented Aug 11, 2021 at 13:46
  • $\begingroup$ @whuber I have edited my question to give a little bit more information about the counts. Hopefully, this has clarified your question $\endgroup$
    – Nick
    Commented Aug 12, 2021 at 9:14
  • $\begingroup$ @Dave It corresponds to a quantity in the sense that if a customer orders mozzarella sticks, fried onion rings, and chips with guacamole at one visit to the restaurant then he has ordered 3 appetizers. The same goes for the main meals $\endgroup$
    – Nick
    Commented Aug 12, 2021 at 9:15

1 Answer 1

1
$\begingroup$

By aggregating data over a year, you might have destroyed a lot of information in the data. As @whuber said in a comment:

Of course there is a correlation. Suppose, arguendo, that most people occasionally order some meals or some appetizers, with no correlation at all (or even with an inverse relation: sometimes all appetizers, sometimes all meals). Regardless, some customers will eat more often at the restaurant than others during a year. This factor alone creates a correlation among the totals. In short, by aggregating the data by years you have likely destroyed most information about any patterns of spending apart from this basic total-consumption-rate signal.

You would be better off looking at the daily (or per visit) data.

$\endgroup$

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.