# How to do a “correlation matrix” with categorical, ordinal and interval variables?

I'm fairly new to statistics and R, and I hope to get your help on this issue. I have a dataset from an experiment with consists of the following variables:

IV1: Age (interval) IV2: Gender (factor) IV3: Condition (factor) IV4: Trait Score (ordinal 10-50) DV1: Reported Happiness (ordinal 0-8) DV2: Reported Intimacy (ordinal 0-9)

#Creating variables
Age <- c(28, 33, 23, 65, 43, 22, 19, 20, 20, 18)
Gender <- c(1, 2, 2, 2, 1, 1, 2, 2, 2, 1)
Condition <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
TraitScore <- c(16, 48, 43, 33, 32, 31, 25, 26, 28, 37)
ReportedHappiness <- c(8, 0, 0, 4, 1, 7, 3, 3, 4, 4)
ReportedIntimacy <- c(9, 9, 0, 4, 2, 8, 8, 0, 5, 2)

#Changing a few classes of variables
Gender <- as.factor(Gender)
Condition <- as.factor(Condition)

#Creating dataframe
Data <- data.frame(Age, Gender, Condition, TraitScore, ReportedHappiness, ReportedIntimacy)


So, my issue is that I would like to do what corresponds to a correlation matrix between all IV's and DV's in the dataset, but how do that when I have a mixture of different types of variables?

Ps. dumbing down is greatly appreciated!

• You don't since correlation does not work for categorical variables, you have to do something else with those, t-tests and such. – user2974951 Oct 2 '18 at 9:24
• Sure, that's why I wrote "...what corresponds to a..." – Marc Andersen Oct 2 '18 at 9:46
• Nice example. So basically you would like to vary correlation method (pearson, spearman etc) depending on the type of variable? If you could be more precise in what methods you want to correspond to your type of variables it would be easier to answer this question programmatically. If this is a statistical question I would suggest StackExchange. – FilipW Oct 2 '18 at 10:26
• Perhaps this Q&A stats.stackexchange.com/questions/73065/… might help you. – mdewey Oct 2 '18 at 16:03