# Find correlations between sets of data

I have observed that I am generally in a better mood after exercising. If I record data on how much I exercise and my mood, how can I correlate these?

Input: discrete events recorded at irregular, unpredictable intervals. Example input data:

• Monday 2pm - Exercise (Moderate, 4/10, or 0.4)
• Monday 5pm - Mood (0.5)
• Monday 9pm - Mood (0.4)
• Tuesday 10am - Mood (0.6)
• Tuesday 12pm - Exercise (Intense, 0.9)
• Tuesday 1pm - Mood (0.7)
• Tuesday 7pm - Mood (0.7)
• Wednesday 1pm - Mood (0.6)
• Thursday 10pm - Mood (0.6)
• Assume observations like these continue for months

Output:

• Correlation strength (how strongly correlated are these?)
• Correlation error (margin of error - what are the odds this correlation is an anomaly of too little data?)
• Correlation phase (are they correlated on a delay - ie does mood rise 30 hours after exercise?)

Note that you cannot assume any kind of line/curve between data points - they are discrete events (in my example - 0.5 exercise on Monday and 0.8 exercise on Tuesday does not mean a steady increase in exercise overnight). Also note that "mood" and "exercise" are arbitrary - they could be swapped out for "vegetables eaten" and "wifi speed".

Looking for the theory at this point, I am not ready to actually do the calculations.

• You seem to imply causation when you say "I am generally in a better mood after exercising." But since you exercise at "irregular, unpredictable intervals" it may be that you are choosing to exercise when you are in or starting on a good mood period. In short, correlation does not prove causation. – Joel W. Oct 5 '14 at 13:06

The general question you are trying to answer is: Is mood independent of exercise? One way they could be dependent is linearly, e.g., for every unit of exercise mood increases by two units -- this linear dependence is what correlation does a great job of measuring.

In order to assess whether the two variables are (in)dependent outside of a particular model, one often begins with a contingency table. In your case, you could setup a contingency table as follows:

                       mood