I will be discussing linear regression,which is a statistical function that is fundamental to analytics, and shows how it may be applied in R.
2024-11-17
I will be discussing linear regression,which is a statistical function that is fundamental to analytics, and shows how it may be applied in R.
If we have the data on individuals’ heights and weights linear regression can model the relationship between height (independent variable) and weight (dependent variable), allowing weight prediction based on a person’s height.
Linear regression establishes a linear relationship between a dependent variable (what we’re predicting) and one or more independent variables (used to predict). The equation governing this relationship is:
\(y = \beta0 + \beta1x + \epsilon\)
y is the dependent variable
\(\beta0\) is the intercept (y-intercept)
\(\beta1\) is the slope
x is the independent variable
\(\epsilon\) is the error term
Above is the representation of the Howell people on their heights and weights.
ggplot(data = howell, aes(x = height, y = weight)) + geom_point() + labs(title = "Weight vs. Height", x = "Height (cm)", y = "Weight (kg)")
ggplot(howell, aes(x = height, y = weight, color = sex)) + geom_line() + labs(title = "Height vs. Weight (Men vs Women)", x = "Height", y = "Weight")
In this multi line plot you will see the height vs weight and the comparisons between the sexes.