官术网_书友最值得收藏!

  • R Programming By Example
  • Omar Trejo Navarro
  • 236字
  • 2021-07-02 21:30:42

Understanding interactions with correlations

The correlation is a measure of the linear relation among two variables. Its value ranges from -1, representing a perfect inverse relation, to 1, representing a perfect direct relation. Just as we created a matrix of scatter plots, we will now create a matrix of correlations, and resulting graph is shown below. Large circles mean high absolute correlation. Blue circles mean positive correlation, while red circles mean negative correlation.

To create this plot we will use the corrplot() function from the corrplot package, and pass it the correlations data computed by the cor() function in R, and optionally some parameters for the text labels (tl), such as color (color) and size (cex).

Variable Correlations

Now, let's look at the following code:

library(corrplot)
corrplot(corr = cor(data_numerical), tl.col = "black", tl.cex = 0.6)

If we look at the relation among the Proportion variable and the other variables, variables in large blue circles are positively correlated with it, meaning that the more that variable increases, the more likely it is for the Proportion variable to also increase. For examples of this type, look at the relations among AdultMeanAge and NoQuals with Proportion. If we find large red circles among Proportion and other variables, it means that the more that variable increases, the more Proportion is likely to decrease. For examples of this type, look at the relations among Age_25to29, Age_30to44, and L4Quals_plus with Proportion:

主站蜘蛛池模板: 日土县| 台东县| 江门市| 南投市| 合山市| 多伦县| 平和县| 富裕县| 夏津县| 大方县| 佛学| 隆安县| 监利县| 博野县| 南城县| 安泽县| 额尔古纳市| 呼玛县| 阿城市| 兴仁县| 黑河市| 漳平市| 汨罗市| 冕宁县| 宁海县| 柳江县| 紫阳县| 大港区| 普定县| 五华县| 忻州市| 泰和县| 香港 | 志丹县| 日喀则市| 运城市| 邯郸县| 静安区| 云浮市| 左云县| 喜德县|