# Goal

I want to find the strength of relationship (correlation) between two variables measured for 40 drivers.

# Data

My dataset has 2 variables, tau_inv = a sensory quantity and ED_bpf = brake pedal force. These are measured repeatedly per driver for 40 drivers. participant name is also included:

    > dput(df)
structure(list(participant = structure(c(33L, 33L, 33L, 17L,
17L, 10L, 4L, 4L, 30L, 29L, 39L, 25L, 37L, 37L, 13L, 13L, 11L,
11L, 11L, 19L, 32L, 6L, 26L, 26L, 27L, 27L, 21L, 21L, 9L, 9L,
18L, 7L, 7L, 38L, 14L, 14L, 35L, 23L, 40L, 40L, 31L, 28L, 16L,
16L, 34L, 34L, 3L, 3L, 12L, 36L, 36L, 15L, 1L, 1L, 1L, 8L, 8L,
2L, 2L, 2L, 24L, 20L, 20L, 5L, 22L), .Label = c("driver: 01",
"driver: 02", "driver: 03", "driver: 04", "driver: 05", "driver: 06",
"driver: 07", "driver: 08", "driver: 09", "driver: 10", "driver: 11",
"driver: 12", "driver: 13", "driver: 14", "driver: 15", "driver: 16",
"driver: 17", "driver: 18", "driver: 19", "driver: 20", "driver: 21",
"driver: 22", "driver: 23", "driver: 24", "driver: 25", "driver: 26",
"driver: 27", "driver: 28", "driver: 29", "driver: 30", "driver: 31",
"driver: 32", "driver: 33", "driver: 34", "driver: 35", "driver: 36",
"driver: 37", "driver: 38", "driver: 39", "driver: 40"), class = "factor"),
tau_inv = c(0.08, 0.11, 0.16, 0.1, 0.17, 0.11, 0.12, 0.19,
0.19, 0.13, 0.09, 0.17, 0.13, 0.14, 0.08, 0.11, 0.08, 0.16,
0.22, 0.19, 0.16, 0.21, 0.13, 0.24, 0.11, 0.11, 0.09, 0.14,
0.15, 0.17, 0.13, 0.14, 0.19, 0.11, 0.17, 0.24, 0.15, 0.19,
0.07, 0.13, 0.25, 0.14, 0.13, 0.22, 0.11, 0.2, 0.16, 0.21,
0.12, 0.13, 0.18, 0.13, 0.05, 0.09, 0.14, 0.16, 0.2, 0.07,
0.14, 0.2, 0.23, 0.12, 0.16, 0.16, 0.15), ED_bpf = c(3.8,
3, 5.5, 1, 5.1, 8.8, 4.1, 12.6, 12.5, 10.8, 5.4, 8, 5.4,
6.6, 3.7, 4.8, 4.2, 3.9, 5.9, 6.8, 11.2, 9.9, 7.2, 8.5, 5.2,
9, 5, 5.5, 5.4, 11, 6.9, 5, 9.2, 7.2, 6.1, 10.6, 9.5, 8.8,
3.3, 8.8, 10, 7.5, 3.4, 7.1, 4, 5, 5.3, 7.9, 10.8, 7, 5.5,
7.8, 4.1, 3.4, 7.8, 5.1, 7.6, 6.4, 3.6, 8.7, 11.4, 5.6, 7,
13.3, 2.4)), row.names = c(NA, -65L), class = c("tbl_df",
"tbl", "data.frame"))


# What I have done

I have estimated the pearson correlation coefficient as shown in the plot below:

library(ggplot2)
library(ggpubr)
ggplot(data = df,
aes(x = tau_inv,
y = ED_bpf)) +
geom_point(alpha = 0.5) +
stat_smooth(method = "lm", se =F) +
stat_cor(method = "pearson", label.x = 0.0025, label.y = 0)


# Question

I am concerned that because there are multiple data points of the same driver (see the participant column), the pearson correlation coefficient might not be the best method to find the strength of the relationship. My concern is due to the reason that if I were to fit a regression model here, it is better to use linear mixed effects model than the simple linear regression model due to the repeated observatios.

So, my question is: Is it okay for me to use pearson correlation coefficient as I am using it here? Or should I use a different method?

It is your decision whether or not to be satisfied with the method, based on your domain knowledge.

Based on your "goal" description, here's what I would do if I were you: since I'm looking for the strength of the relationship between those 2 variables, I'm perfectly fine using the correlation coefficient. I'm considering each pair of data as a separate experiment. If some of the drivers "conducted" more than just one experiments for me, that's perfectly fine, those experiments are still valuable.

However, if you wanted to take into account who the actual driver is, that's a different story. For example, if you wanted to investigate which driver reacted faster (e.g. were they drunk or not while driving, in case they are even human), then you could compare the measurements and see who's reacting too slow even with strong sensory input.

• Thanks. This makes sense. I am going ahead with the correlation coefficient. – umair durrani Aug 24 '20 at 1:17

If you're just calculating the statistical metric of the correlation, that statistical measure is the same regardless of how the data is generated. However, there can be problems with further interpretations of that metric. For instance, I see that a p-value of 0.000009 is included on your graph. The p-value depends on both the correlation coefficient and the number of observations, and assumes that those observations are independent. Since they aren't independent, the p-value is not reliable. A related issue is Simpson's paradox.

An example of how using simple correlation would lead to too strong of a conclusion: suppose you're looking the correlation between exercise and diet, and you look at just two people (say, Alice and Bob). Normally, calculating the p-value for $$n=2$$ is useless; you're always going to get $$r=1$$, so an $$r$$ of $$1$$ is not significant. If you look at these two people over a thousand days, and record this as $$n = 2000$$, you're going to be overestimating the significance. Any difference between Alice and Bob is going to look like a correlation between exercise and diet, when it's really just a difference between Alice and Bob.

If Alice does a lot of exercise and doesn't eat much, and Bob eats a lot and doesn't exercise much, then it's going to look like there's a negative correlation between exercise and diet. The stronger the difference between Alice and Bob, compared to the differences within each person's individual numbers, the stronger the correlation will appear. There's going to be a dependence between the data points in that if a datapoint has high exercise, it's probably one of Alice's data points, and thus probably has low diet.

• Thanks. I better not include the p-value then. – umair durrani Aug 25 '20 at 1:30
• I would add that considering experiments done by the same driver as independent or dependent is also a decision influenced by business domain knowledge, not just quantitative methodology. I have a strong intuition that in your case, these experiments would still satisfy the criteria of independence. Think of something like this: just because you have already measured one of the driver's data once, does that mean that the same driver's next data collection is compromised or biased? For example, does the driver know about it and next time, would be more careful – Balázs Pukli Aug 25 '20 at 20:00
• @BalázsPukli It's possible that the data is independent, but assuming that it's independent is no longer valid. The driver doesn't need to be "compromised". If each driver has their own mean for the two metrics, then their data will cluster around those means. I've edited to try to make that clearer. – Acccumulation Aug 25 '20 at 20:31