Session Ready
Exercise

Nonparametric correlation (2)

In the last exercise we calculated the Spearman correlation coefficient between education level and craft beer consumption. We now know our absolute correlation coefficent, yet we do not know whether this is significantly different from 0. In order to test this, we can use the R function cor.test(). In addition to calculating the correlation coefficient, this function also tests the hypothesis whether our obtained correlation coefficient is different from 0.

The function cor.test() accepts the same parameter as the function cor(). You can provide it with an x and y vectors. Also, you specify the method parameter to be "spearman"

Instructions
100 XP
  • In your console, a dataframe called beer_data is available which contains the frequency of craft beer consumption. This frame contains the variables education_level which represents the highest completed education level of a respondee. 1 represents primary school, 2 high school, 3 bachelor, 4 master, 5 PhD. The variable consumption represents the frequency with which the respondee consumes craft beer. 1 represents never, 2 rarely, 3 occassionally, 4 often and 5 very often. Using the R function cor.test(), calculate the correlation coefficient, test whether it is is different from zero and print the output to the console.
  • Is the null hypothesis of the correlation coefficient being equal to 0 accepted or rejected? Assign either the value of "accepted" or the value of "rejected" to the variable conclusion