2
$\begingroup$

I'm doing a personal project and would like to see if High Caloric Food has a statistical significance on Weight Level.

I've tried Chi Squared Contingency test as suggested by chatgpt but it gives a p-value of 1 which fails to reject null hypothesis that there is no association between High Caloric Food and Weight Level. Visually I can see that High Caloric Food does increase the Obesity Count.

What test should I use in this scenario?

Code:

weight_order = ['Normal_Weight', 'Overweight_Level_II', 'Insufficient_Weight', 'Overweight_Level_I', 'Obesity_Type_I', 'Obesity_Type_II', 'Obesity_Type_III']

df[['High Caloric Food Freq', 'Weight Level']].groupby('High Caloric Food Freq').value_counts(normalize=True).reindex(weight_order, level=1).unstack()

I've normalized the data since the 'yes' to High Caloric Food count is almost 3x greater than 'no'.

Here is what the table looks like:

A 2x7 contingency table showing row-wise proportions, with "High Caloric Food Freq as rows, and "Weight Level" as columns. "High Caloric Food Freq" is a binary variable ("Yes/No") and "Weight level" is an ordinal variable with 7 different values.

Edit: sorry for the confusion. The numbers represent the proportion of each weight level that answered 'no' or 'yes' to frequent High Calorie food consumption. For example, 32.24% who have answered 'no' to frequent high calorie consumption have a normal weight.

$\endgroup$
4
  • $\begingroup$ Please explain what the numbers in your table mean and how they were measured. $\endgroup$
    – whuber
    Nov 28, 2023 at 21:50
  • 1
    $\begingroup$ Do you have actually weights and heights? What order is obesity level in? (That is, is obesity level III the heaviest)? It looks like the cells in your table are row proportions, but chi-square uses counts. What do you mean by "normalizing" the data? $\endgroup$
    – Peter Flom
    Nov 28, 2023 at 22:31
  • $\begingroup$ sorry for the confusion. The numbers represent the proportion of each weight level that answered 'no' or 'yes' to frequent High Calorie food consumption. For example, 32.24% who have answered 'no' to frequent high calorie consumption have a normal weight $\endgroup$
    – Oscar Yip
    Nov 28, 2023 at 23:13
  • 1
    $\begingroup$ How many observations do you have in your dataset? $\endgroup$
    – J-J-J
    Nov 29, 2023 at 16:54

1 Answer 1

6
$\begingroup$

As Peter Flom points out in comments, a chi-square test requires to use counts, not proportions (that is, in your code, you should set the normalize parameter to False, not True). The fact that you have much larger counts of "yes" than "no" does not change that.

The sample size has a direct impact on the p-value. If you feed the chi-square test a table where you removed information about the sample size (like you did), you can't trust the results the test gives you. That's why you need to provide the actual counts, not the percentages.

On a side note, if you're in the specific case of some complex survey sampling design, you may want to use the survey weights associated to the observations along with the Rao-Scott chi-square test (instead of the "vanilla" chi-squared test). But even in this case you have to provide the counts as input, not proportions.

Note that if you have a very large number of observations, a test may be not necessary to judge if there is a difference between the two groups in the population, given the differences of percentages in your table.

Besides a chi-squared test, an interesting method when the outcome is ordinal, is ordinal regression. You can find several online resources about it, including questions and answers on this website; having a look at Frank Harrell's website should be informative too.

In any case, you should also focus your attention on a better visualization of your data if you intend to present the data to other people. You could for example consider using bar plots, instead of a table that uses an order that is quite confusing. For instance, why did you voluntarily put "Insufficient_Weight" between "Overweight_Level_II" and "Overweight_Level_I"? This is confusing, if one wants to see how the percentages change in the two groups, as we move from the weight level "Insufficient weight" to "Obesity type III".

$\endgroup$
5
  • 1
    $\begingroup$ How do you deduce the first row represents "at least 1 million" observations? The top row can be expressed (to the precision given) as the vector $(79, 74, 51, 22, 11, 7, 1)/245,$ strongly suggesting the total number of observations in that row is either 245 or (possibly) 490, but no larger. $\endgroup$
    – whuber
    Nov 29, 2023 at 15:22
  • $\begingroup$ @whuber Indeed, my bad. I checked the irreducible fractions of the values in the table, but I was assuming that the given values were not rounded, which may be an incorrect assumption. I delete my answer, sorry for the inconvenience. $\endgroup$
    – J-J-J
    Nov 29, 2023 at 15:26
  • 1
    $\begingroup$ There's nothing the matter with your advice, though. You might consider illustrating it using the inferred counts. For the record, the second row equals $(208, 216, 221, 268, 340, 290, 323)/1866$ (to six decimal places). $\endgroup$
    – whuber
    Nov 29, 2023 at 15:27
  • 1
    $\begingroup$ @whuber Thanks. This is the occasion for me to dive into continued fractions. There's another information that OP gave, to probably take into account: the total counts in the second row are about 3 times the total counts in the first row. If I have some time one of these days, I think I'll probably ask a question on how to solve this problem :) $\endgroup$
    – J-J-J
    Nov 30, 2023 at 9:01
  • $\begingroup$ In case someone is interested, I asked a follow-up question relative to the discussion above: stats.stackexchange.com/questions/632731/… $\endgroup$
    – J-J-J
    Nov 30, 2023 at 17:16

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.