Module 8: Visualizing Correlation & Regression with ggplot2
Few stresses the importance of correlation not implying causation, or that X is not generally the cause of Y. However, I think the argument can be made that it's at least involved to some degree, as we'll see in the results of my ggplot code below:
As we can see by the graph's spotty plotting and the downward trend of the regression line, x (mpg) and y (carb) do not have much correlation, implying the two are practically distant factors. Now, let's view another example:
cyl and hp have a greater correlation, resulting in tighter dots on the scatter plot and an upwards trend of the regression line. Even though it's cleat that the amount of cylinders doesn't improve horsepower in all instances (some dots with 6 cylinders have less hp than 4-cylinder ones), the connection is still made discernible.
GitHub link for code: https://github.com/Retrolovania/R_Programming/blob/main/Module%208.R
Comments
Post a Comment