Section 7.7 Coefficient of Determination (R^2)
Once you have a correlation coefficient, whatβs next? Well, with the correlation coefficient, we can then calculate R^2, otherwise known as the coefficient of determination, which measures the proportion of variance in one variable that is explained by the other. In simple correlations, RΒ² is just rΒ², the square of the correlation coefficient.
R^2 tells us how much of the variance in Y is explained by X. We can use a combination of the
cor command and base R.
# R^2 tells us the percentage of variance shared between two variables.
# Calculating the R^2 value
cor(examData$anxiety_score, examData$exam_score)^2
# Making it look pretty
round(cor(examData$anxiety_score, examData$exam_score)^2*100,2)
# What about the others?
cor(examData$studying_hours, examData$exam_score)^2*100
cor(examData$studying_hours, examData$anxiety_score)^2*100
[1] 0.197938 [1] 19.79 [1] 15.21327 [1] 50.72625
The above values are saying:
-
19.45% of all the variation of exam scores is associated with anxiety.
-
15.74% of all the variation of exam scores is associated with studying time.
-
50.30% of all the variation of anxiety scores is associated with studying time.
Number three seems particularly strong. There may be more to investigate here.
