# What type of test to use to determine correlation/relationship between two non-continuous varaibles

I need to determine if there is any relationship between two count variables. I have 60+ observations for 4 variables and I want to see if any of the pairs of these variables are significantly correlated with one another.

Mostly I use R, so forgive me if you're not familiar.

I have been using the cor(...,method="pearson") and cor.test() functions to test each pair, but now I'm not so sure that this is the right approach/test. Would a non-linear regression like glm(...,family="poisson") be more appropriate?

I started thinking like this because when I looked at a histogram of the counts across my observations, I noticed that there seemed to be a slight tendency for the pink and green variables to go up and down to together.

I produced a scatter plot of each of the variables plotted against each of the other variables. I used the tests mention above to try and quantify this relationship and to test weather it was real or just noise.

-
Do you have any thoughts about what kind of relationships might exist? Do you think these are a function of something? Eg, do you think var1 might be caused by var2, or some factor outside of these 4 vars? Do you think they might all serve as measures of the same underlying construct? One thing to bear in mind is that since they are counts, they should be distributed as Poisson; so, eg, taking logs may be appropriate. – gung Mar 18 '12 at 14:54
No thoughts as to what might be there. I will add some images to the above post to show why I started thinking this way. Perhaps that might help. – Davy Kavanagh Mar 18 '12 at 15:02
also for the scatter plots I removed the massive outlier in YY1. – Davy Kavanagh Mar 18 '12 at 15:11
It strikes me that you could look at the correlation matrix of the four variables. You can do this by putting all the data into one data.frame, and then run cor(). For a simple test to see if correlations EXIST, you could use something like cortest.bartlett(my.correlation.matrix, n=60), but that doesn't help you find out what the relationships are. If you follow @gung 's answer below, you could look at the correlation matrix to gather intuition about what relationships might exist, and then run a new study to investigate those suspected relationships. – Oliver Mar 18 '12 at 17:34

What you are doing is exploratory data analysis. Because you looked at your data first, and then decided to test something specific based on what you just saw, sample statistics (like r-scores) are going to be biased, and inferential statistics (like p-values) would not mean what they are purported to mean. (If that doesn't make sense, you may want to read my answer to a different question here, which should make the underlying ideas more understandable, although the ideas are applied in a different context.) To be clear, I have nothing against exploratory data analysis--I'm quite fond of it, it's just important to realize which game you're playing and what that means for how you think about what you're doing and what you find. With that in mind, I would take the log of all your counts (looking at your numbers, I would probably use log base-2, then each unit would be interpretable as a doubling of the underlying count). Then I would simply make a scatterplot matrix overlaid with loess lines. In R, in the car package, scatterplot.matrix() will do this for you and make it pretty. I would then just use my judgment to assess the situation because of the bias issues noted above. If you want a formal model and hypothesis tests, I would figure out what I thought might be true (and if it were interesting & important, etc.) and then gather a new dataset specifically to test that hypothesis.

-
 +1 for reminding people of assumptions. Of course, with p-values, most people interpret them incorrectly even when the assumptions are met, but that's a different issue. – Peter Flom Mar 18 '12 at 19:20 This is really clear and helpful, thank you! – Davy Kavanagh Mar 18 '12 at 20:26 Very clear, thoughtful, useful. Which is no surprise :-) – rolando2 Mar 18 '12 at 20:42

If you have no assumptions whatsoever and you simply want to see if any of the variables are correlated with the outcome then just use

regress1<-lm(y~x1+x2+x3+x4)


and don't complicate your life ;) ... just look if the t-statistic is >2 for any of the explanatory variables and you've got some correlations that are statistically significant.

However, if you want to fit the best model possible then you'd have to provide more input about what sort of data you have.

-