Correlation between event occurrence and data

I'm trying to figure out what's causing my stomach pain recently and I have logged the following data twice a day:

• A grade on a scale from 1 to 10 on how much my stomach hurts
• Foods (unique names) I've been eating (e.g., banana, yogurt, tomatoes) twice a day also

So I have my data like the following (almost 3 months of data, so ~120 lines):

14/06 AM    5    banana, tomatoe
14/06 PM    3    milk, beans, banana
15/06 AM    2    apple, meat, tomatoe
15/06 PM    3    chicken, banana, coffee
16/06 AM    6    milk, beans, chicken
16/06 PM    7    tomatoe, orange, coffee
...


How can I find the correlation (or combined occurrences) between those two set of data? Like the more I eat tomatoes with bananas, the higher my stomach hurts?

I know how to figure out the correlation between two sets of discrete values, but here I have discrete values (pain) and occurrences (food). Is there a formula for this? Can I use R?

Complementary question: I have a third column where I input how much water I drank (5 oz, 3 oz)... How can I include it in my stats ?

• If the truth is anything beyond a single food causing problems & the rest not, you are going to need a lot of data. Jun 18, 2016 at 0:02
• Please register &/or merge your accounts (you can find information on how to do this in the My Account section of our help center), then you will be able to edit & comment on your own question. Jun 18, 2016 at 0:29

In order to analyse this you'd use an ordinal probit regression with the dependent variable being your pain rating, and the independent variable(s) being the food and the quantity of water.

Such a model would assume that your ratings of pain map onto an underlying continuous latent variable (the amount of pain you're experiencing), and would model how that latent variable varies as a function of the food you're eating and the volume of water you consume.

As gung has pointed out though, if you're interested in looking at the combination of foods then you'll need vast numbers of observations (you'd want to have a reasonable number, maybe >5, of each combination).

Really, though, if you're experiencing pain which you believe is related to your diet then either altering your diet (on the basis of patterns you observe) or seeking professional help is more important than determining the appropriate statistical approach to take

Basically you have a regression problem where a number of binary coded fruit (variable is either 0 or 1) predicts a pain score. If you want the door to all sorts of combination effects, a machine learning technique is probably better suited then a probit model. Consider a random forest or a neural network or ... They will respect all the combinations that you feed them (no pun intended) without forcing you to try all possible combinations. They will try to draw all the information from your 120 observations and find a model that fits these observations.

Be warned though, that 120 orbservations is not that much (depending on the number of possible foods) and it may well be, that many different models might fit your data and that the model found by an algorithm does not reflect your biological reality well.

That being said, I'd try a regression tree as well as a random forest. And yes, you can use R to compute both. There will be a lot of explanations and examples on the web. I'd recommend starting with Youtube searching for "StatQuest" and the topic at hand, but that is a weakly founded personal preference.

If given the sample size, interactions are not that important, you might also want to look into Naive Bayes, which is also explained in a StatQuest video : https://www.youtube.com/watch?v=O2L2Uv9pdDA